File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 44 :license {:name " Eclipse Public License"
55 :url " http://www.eclipse.org/legal/epl-v10.html" }
66 :plugins [[lein-ring " 0.8.7" ]]
7- :ring {:handler project1.core/route -handler
7+ :ring {:handler project1.core/wrapping -handler
88 :init project1.core/on-init
99 :port 4001
1010 :destroy project1.core/on-destroy}
Original file line number Diff line number Diff line change 1919 (println x " Hello, World!" ))
2020
2121(defn test1-handler [request]
22+ (throw (RuntimeException. " error!" ))
2223 {:body " test1" })
2324
2425(defn test2-handler [request]
3031 " /test2" (test2-handler request)
3132 " /test3" (handlers/handler3 request)
3233 nil ))
34+
35+ (defn wrapping-handler [request]
36+ (try
37+ (if-let [resp (route-handler request)]
38+ resp
39+ {:status 404 :body (str " Not found: " (:uri request))})
40+ (catch Throwable e
41+ {:status 500 :body (apply str (interpose " \n " (.getStackTrace e)))})))
You can’t perform that action at this time.
0 commit comments