In some cases, exception.cause may be null , so it is recommended that you use a conditional expression to display the message:
[(exception.cause!=null)?(exception.cause.message):exception]
This will prevent the null pointer from being thrown .
source share