Browse files

Implemented suggestion from Thomas Lee for more descriptive exception…

… when no matching routes
  • Loading branch information...
1 parent 8b5da2e commit 3f0b5a4b0247d5b95526b777bf3be17fc7ac86c8 @weavejester committed Jun 13, 2009
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/compojure/http/servlet.clj
@@ -104,9 +104,11 @@
(defn request-handler
"Handle incoming HTTP requests from a servlet."
[[servlet request response] routes]
- (do (.setCharacterEncoding response "UTF-8")
- (update-servlet-response response
- (routes (create-request request servlet)))))
+ (.setCharacterEncoding response "UTF-8")
+ (if-let [response-map (routes (create-request request servlet))]
+ (update-servlet-response response response-map)
+ (throw (NullPointerException.
+ "Handler returned nil (maybe no routes matched URI)"))))
(definline servlet
"Create a servlet from a sequence of routes. Automatically updates if

0 comments on commit 3f0b5a4

Please sign in to comment.