Check for null message when getting the exception message

This commit is contained in:
nathan 2017-08-17 15:25:21 +02:00
parent 545fef3a7e
commit c6ada706d6
1 changed files with 9 additions and 4 deletions

View File

@ -304,14 +304,19 @@ class OS {
/**
* @return the first line of the exception message from 'throwable'
* @return the first line of the exception message from 'throwable', or the type if there was no message.
*/
public static
String getExceptionMessage(final Throwable throwable) {
String message = throwable.getMessage();
int index = message.indexOf(OS.LINE_SEPARATOR);
if (index > -1) {
message = message.substring(0, index);
if (message != null) {
int index = message.indexOf(OS.LINE_SEPARATOR);
if (index > -1) {
message = message.substring(0, index);
}
} else {
message = throwable.getClass()
.getSimpleName();
}
return message;