Uncaught Exceptions in Clojure

Uncaught exceptions in Clojure sometimes disappear into the void if they happen in a background thread. Fortunately, the JVM provides a hook for adding a default handler:

  (Thread/setDefaultUncaughtExceptionHandler
   (reify Thread$UncaughtExceptionHandler
     (uncaughtException [this thread throwable]
       ;; do something with the exception here.. log it, for example.
       )))

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>