Skip to content

Commit

Permalink
Exceptions caught by 500.scaml should set the status to 500.
Browse files Browse the repository at this point in the history
  • Loading branch information
rossabaker committed Mar 8, 2012
1 parent 3233ab7 commit 9d4385c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -128,6 +128,7 @@ trait ScalateSupport extends ScalatraKernel {
// Hack: Have to pass it the request and response, because we're outside the
// scope of the super handler.
private def renderScalateErrorPage(req: HttpServletRequest, resp: HttpServletResponse, e: Throwable) = {
resp.setStatus(500)
resp.setContentType("text/html")
val errorPage = templateEngine.load("/WEB-INF/scalate/errors/500.scaml")
val context = createRenderContext(req, resp, resp.getWriter)
Expand Down
Expand Up @@ -28,7 +28,8 @@ class ScalateSupportSpec extends ScalatraSpec { def is =
"implicitly bind session" ! e19^
"implicitly bind params" ! e20^
"implicitly bind multiParams" ! e21^
"render to a string instead of response" ! e22
"render to a string instead of response" ! e22^
"set status to 500 when rendering 500.scaml" ! e23

addServlet(new ScalatraServlet with ScalateSupport
with ScalateUrlGeneratorSupport with FlashMapSupport with CookieSupport {
Expand Down Expand Up @@ -218,4 +219,8 @@ class ScalateSupportSpec extends ScalatraSpec { def is =
def e22 = get("/render-to-string") {
header("X-Template-Output") must_== "<div>SSP template</div>"
}

def e23 = get("/barf") {
status must_== 500
}
}

0 comments on commit 9d4385c

Please sign in to comment.