Skip to content

Commit

Permalink
updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Burnett committed Nov 20, 2012
1 parent e75f0c0 commit 320a257
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.markdown
Expand Up @@ -129,12 +129,24 @@ object App {
render.plain("we never make it here").toFuture
}

/**
* Custom Error Handling with custom Exception
*
* curl http://localhost:7070/unautorized
*/
class Unauthorized extends Exception

get("/unauthorized") { request =>
throw new Unauthorized
}

error { request =>
request.error match {
case Some(e:ArithmeticException) =>
render.status(500).plain("whoops, divide by zero!").toFuture
case Some(e:Unauthorized) =>
render.status(401).plain("Not Authorized!").toFuture
case _ =>
println(request.error)
render.status(500).plain("Something went wrong!").toFuture
}
}
Expand Down

0 comments on commit 320a257

Please sign in to comment.