At Spring Boot Whenever a bad Nullpo (the one who made the bug is really bad) comes out, I'm in trouble because I can't keep up with it, so I decided to attach a handler that issues a stack trace to the bottom of the Controller. Surprisingly useful for debugging.
@ExceptionHandler({NullPointerException.class})
public String handleRunTimeException(NullPointerException ex) throws IOException {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String stackTraceString = sw.toString();
log.error(stackTraceString);
sw.close();
pw.close();
return "redirect:error/500";
}
Recommended Posts