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

500 error 500.scaml template not having correct content-type #47

Closed
octplane opened this issue Mar 30, 2011 · 8 comments
Closed

500 error 500.scaml template not having correct content-type #47

octplane opened this issue Mar 30, 2011 · 8 comments

Comments

@octplane
Copy link

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.

@rossabaker
Copy link
Member

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?

@octplane
Copy link
Author

octplane commented Apr 8, 2011

I have no custom error block. Maybe this is where I should do something ?

@rossabaker
Copy link
Member

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.

@octplane
Copy link
Author

https://github.com/octplane/scalatra-issue-47

./sbt
update
jetty

and go to http://localhost:8080/500/

The 500 page is sent as text/plain.

@casualjim
Copy link
Member

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

@rossabaker
Copy link
Member

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:

- response.setContentType("text/html")

@octplane
Copy link
Author

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 !

@octplane
Copy link
Author

I suppose I can destroy the test project now ?

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

3 participants