-
-
Save rightfold/66b0397e1b1ad3e265e6 to your computer and use it in GitHub Desktop.
This file contains 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
(defn fatal? [e] | |
(some #(instance? % e) #{StackOverflowError VirtualMachineError ThreadDeath InterruptedException LinkageError})) | |
(defn catching [f] | |
(fn [& args] | |
(try | |
[:ok (apply f args)] | |
(catch Throwable e (if (fatal? e) (throw e) [:error e]))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment