[2.4 Java] New error handling with HttpErrorHandler not printing the full stack to log

110 views
Skip to first unread message

Fabian Gilson

unread,
Jul 2, 2015, 10:00:05 AM7/2/15
to play-fr...@googlegroups.com
Hi,

I'm finishing to upgrade to Play 2.4 and I moved out the error handling from the Global thing. However, it seems that when the onServerError is called, the full stack is not printed anymore into the log file. I tried to retrieve the exception stack, but I can't get it all, only the last exception. I tested with and without binding my own error handler and the stack is actually printed with full details if I do not register my own error handler.

My code as defined before (only the method name changed), is
public Promise<Result> onServerError(RequestHeader request, Throwable t) {
 
return Promise.<Result> pure(internalServerError(
    error
.render(t, play.data.Form.form(Login.class))
 
));
}

I added some code to print the current trace, but even if I try to access the cause, it's said as being null:
StringWriter sw = new StringWriter();
exception
.printStackTrace(new PrintWriter(sw));
logger
.debug(sw.toString());

Any advice ?
Thanks a lot,
Fabian

alex s

unread,
Jul 3, 2015, 5:38:33 PM7/3/15
to play-fr...@googlegroups.com
четверг, 2 июля 2015 г., 17:00:05 UTC+3 пользователь Fabian Gilson написал:
Hi,

I'm finishing to upgrade to Play 2.4 and I moved out the error handling from the Global thing. However, it seems that when the onServerError is called, the full stack is not printed anymore into the log file. I tried to retrieve the exception stack, but I can't get it all, only the last exception. I tested with and without binding my own error handler and the stack is actually printed with full details if I do not register my own error handler.

My code as defined before (only the method name changed), is
public Promise<Result> onServerError(RequestHeader request, Throwable t) {
 
return Promise.<Result> pure(internalServerError(
    error
.render(t, play.data.Form.form(Login.class))
 
));
}

That's because exception logging code is located at https://github.com/playframework/playframework/blob/2.4.x/framework/src/play/src/main/java/play/http/DefaultHttpErrorHandler.java#L133. Extend DefaultHttpErrorHandler and then override onProdServerError method.

Fabian Gilson

unread,
Jul 6, 2015, 8:29:13 AM7/6/15
to play-fr...@googlegroups.com
Thanks a lot, did not read the migration guide carefully enough.
F/
Reply all
Reply to author
Forward
0 new messages