Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ResponseBody.Writer failure #17

Open
danneu opened this issue Feb 6, 2017 · 0 comments
Open

Handle ResponseBody.Writer failure #17

danneu opened this issue Feb 6, 2017 · 0 comments

Comments

@danneu
Copy link
Owner

danneu commented Feb 6, 2017

Since a ResponseBody.Writer is piped to the jetty response object after the kog response is returned from the handler, if the writer throws an error, then kog (e.g. the user's custom error handler) does not handle it. Jetty handles it and displays a blank 500 response.

This is the logic right now:

val request = kog.Request.fromServletRequest(jettyServletRequest)
val response = handler(request)
response.body.pipe(jettyServletResponse)

For instance, Pebble (http://www.mitchellbosecke.com/pebble/home) writes a to Writer.

val template: PebbleTemplate = engine.getTemplate(path)
return Response().writer("text/html") { writer -> template.evaluate(writer, data) }

So if there's an error in the template, like {{ doesNotExist() }}, then you'll get a blank Jetty 500 page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant