This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-15
Channels
- # beginners (97)
- # boot (54)
- # cider (13)
- # cljs-dev (3)
- # cljsrn (9)
- # clojure (64)
- # clojure-berlin (1)
- # clojure-brasil (119)
- # clojure-dev (3)
- # clojure-france (5)
- # clojure-greece (1)
- # clojure-italy (5)
- # clojure-madison (1)
- # clojure-russia (15)
- # clojure-spec (25)
- # clojure-uk (57)
- # clojurebridge (5)
- # clojurescript (45)
- # code-art (1)
- # community-development (17)
- # cursive (24)
- # datomic (83)
- # emacs (11)
- # fulcro (70)
- # hoplon (7)
- # immutant (3)
- # leiningen (19)
- # luminus (5)
- # lumo (25)
- # onyx (123)
- # other-languages (7)
- # pedestal (2)
- # re-frame (12)
- # ring (15)
- # ring-swagger (51)
- # shadow-cljs (89)
- # spacemacs (23)
- # sql (4)
- # unrepl (57)
- # utah-clojurians (1)
- # vim (1)
i'm trying to set up logging with timbre in my luminus app. is there a point where I can plug in my own function so i can log exceptions? i set up an unhandled exception handler, but something is already capturing exceptions, it's just not obvious to me what
@lucian303 which kind of exceptions? From async operations? Is it possible that you are using futures?
@jumar just regular exceptions. for example, i added this route and would like to log the exception somehow:
(GET "/error" []
:summary "Error"
(throw (Exception. "An error has occurred")))
this is something that ring middleware is for - check e.g. https://8thlight.com/blog/mike-knepper/2015/05/19/handling-exceptions-with-middleware-in-clojure.html
@jumar thanks, that's one of the solutions i'm trying to implement. unfortunately, the exception is never caught. i removed all other middleware, but something is still capturing it, i suspect, because my catch block never gets run.
(defn wrap-exception-handler [handler]
(fn [request]
(try (handler request)
(catch Exception e
(println "logged error")
(timbre/error e)
{:status 500 :body "An error occurred"}))))