[New] Added StringHelper.getExceptionMessage(Throwable)

This commit is contained in:
Robert von Burg 2015-03-22 00:33:59 +01:00
parent 8e75a7651a
commit 6338690ad2
1 changed files with 17 additions and 0 deletions

View File

@ -563,6 +563,23 @@ public class StringHelper {
}
}
/**
* <p>
* Returns a message for the given {@link Throwable}
* </p>
*
* <p>
* A {@link NullPointerException} only has <code>null</code> as the message so this methods returns the class name
* in such a case
* </p>
*
* @param t
* @return
*/
public static String getExceptionMessage(Throwable t) {
return StringHelper.isEmpty(t.getMessage()) ? t.getClass().getName() : t.getMessage();
}
/**
* Formats the given {@link Throwable}'s stack trace to a string
*