Cheers,
Aaron
You'd want some middleware like this:
(defn with-error-catching [handler]
(fn [request]
(try
(handler request)
(catch Exception e ;; handle the exception
...))))
And then you'd use the decorate macro to add it onto your routes:
(decorate your-routes with-error-catching)
- James
> --
> You received this message because you are subscribed to the Google Groups "Compojure" group.
> To post to this group, send email to comp...@googlegroups.com.
> To unsubscribe from this group, send email to compojure+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/compojure?hl=en.
>
>
(defn error-handling
[handler]
(fn [request]
(try
(handler request)
(catch Exception e
(if (= "development" environment)
(handler request)
(do
(log :error e)
[500 "Application Error"]))))))
I have setup environments so that production doesn't produce a stack trace straight to the browser but development will.
Cheers,
Aaron
On Jan 5, 2010, at 5:05 PM, James Reeves wrote: