lighttp
lighttp copied to clipboard
Log exceptions when thrown
Currently, if an exception is thrown in a user-provided handler, it will get silenced. The only trace of the exception will be the "500 Server Error" page and the error message nor stack trace are not recoverable.
The suggestion is to make them possible to log, and add a new option eg. printExceptions, preferably on by default. For example, handleRouteCatch could be expanded to include a stderr.writeln call:
private void handleRouteCatch(ref HandleResult result, AsyncTCPConnection client, ServerRequest req, ServerResponse res) {
try this.server.router.handle(this.server.options, result, client, req, res);
catch(Exception ex) {
import std.stdio;
res.status = StatusCodes.internalServerError;
stderr.writeln(ex);
}
}
Can self-assign.