Check for null message when getting the exception message
This commit is contained in:
parent
545fef3a7e
commit
c6ada706d6
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user