Created
June 26, 2012 14:47
-
-
Save ifesdjeen/2996213 to your computer and use it in GitHub Desktop.
Global Exception catching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; That will actually catch exception within inner thread, too. And within inner thread of inner thread. Etc. | |
(Thread/setDefaultUncaughtExceptionHandler (proxy [Thread$UncaughtExceptionHandler] [] | |
(uncaughtException [t e] | |
;; | |
;; Your fancy Exception logging here | |
;; | |
(println "Throwable: " + (.getMessage e)) | |
(println (.toString t))))) | |
(.start (Thread. (cast Runnable | |
(fn [] | |
(throw (Exception. "INNER THREAD EXCEPTION!!")))))) | |
;;Throwable: #<core$_PLUS_ clojure.core$_PLUS_@292ade54> INNER THREAD EXCEPTION!! | |
;;Thread[Thread-1,5,main] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment