Fork me on GitHub
#luminus
<
2017-11-15
>
lucian30302:11:22

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

jumar08:11:15

@lucian303 which kind of exceptions? From async operations? Is it possible that you are using futures?

lucian30318:11:07

@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")))

lucian30322:11:31

@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"}))))