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
500 error 500.scaml template not having correct content-type #47
Comments
ScalateSupport#handleError first calls ScalatraKernel#handleError to let the error block run. If that error block returns a value, then that result will be rendered just like a typical action, with the same content type inference. If that error block rethrows the exception, then it is rendered with the Scalate error console as text/html. Do you have a custom error block? If so, what is it returning? Could you set the content type there? |
I have no custom error block. Maybe this is where I should do something ? |
The default error block just rethrows the exception, which should result in the Scalate console being displayed as text/html. This works for me. If you can post a minimal application with the problem, then I can try to figure out how yours is different. |
https://github.com/octplane/scalatra-issue-47
and go to http://localhost:8080/500/ The 500 page is sent as text/plain. |
nice one... this bug should be fixed on the akka-integration branch... we might be able to put that in master in the next week or so |
Thank you for the test project -- that is a big help! The reason I couldn't reproduce this was that I was using the 500.scaml out of the Scalate jar. That version explicitly sets the content type. You overrode that file without setting the content type. I just explicitly set it in ScalateSupport.renderErrorPage, so error pages will now default to text/html. Until the next release, the workaround is to add this to your template:
|
Ha ! So there is a way to do that directly in the template. That's cool. (my first goal was to have a 500 in json... :)). Thanks for the supports guys ! |
I suppose I can destroy the test project now ? |
Because there is no content type set by ScalateSupport#handleError, it is inferred at a later stage by Scalatra as text/plain.
I'd suggest that ScalateSupport#handleError set the content-type to text/html, a reasonable default.
The text was updated successfully, but these errors were encountered: