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 public static
String getExceptionMessage(final Throwable throwable) { String getExceptionMessage(final Throwable throwable) {
String message = throwable.getMessage(); String message = throwable.getMessage();
int index = message.indexOf(OS.LINE_SEPARATOR); if (message != null) {
if (index > -1) { int index = message.indexOf(OS.LINE_SEPARATOR);
message = message.substring(0, index); if (index > -1) {
message = message.substring(0, index);
}
} else {
message = throwable.getClass()
.getSimpleName();
} }
return message; return message;