Skip to content

Default exception handler does not log exceptions (but prints to stdout) #172

Closed
@briankontor

Description

@briankontor

We noticed that uncaught exceptions in our api were not being logged and found that the default exception handler safe-handler calls printStackTrace instead of logging the exception.

A small but useful change might be something like:

(defn safe-handler
  "Copy of the version in compojure api that uses log instead of printStackTrace
  See https://github.com/metosin/compojure-api/blob/master/src/compojure/api/exception.clj#L13"
  [^Exception e _ _]
  (clojure.tools.logging/spy :error e) ;; was (.printStackTrace e)
  (internal-server-error {:type "unknown-exception"
                          :class (.getName (.getClass e))}))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions