I was catching an exception and trying to write the stack trace to the logs like this:
log.warn(e.getMessage());
But all it said was
In your exception method, the underlying String
which contains the message is null
.
The above answer, now struck out, still holds, except that e
is not null, but the detailMessage
private instance variable on the Throwable
class is null, which is why e.getMessage()
is the String null
, but e.toString()
(which calls underlying null detailMessage.toString
) throws a NullPointerException
.