From 320a25766532ca6dd4e6758cd915d642064e9177 Mon Sep 17 00:00:00 2001 From: Christopher Burnett Date: Tue, 20 Nov 2012 13:27:06 -0800 Subject: [PATCH] updated README --- README.markdown | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 220031db75..a2e2f170cf 100644 --- a/README.markdown +++ b/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 } }