Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated README

  • Loading branch information...
commit 320a25766532ca6dd4e6758cd915d642064e9177 1 parent e75f0c0
@twoism twoism authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 README.markdown
View
14 README.markdown
@@ -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
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.