Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightfold/66b0397e1b1ad3e265e6 to your computer and use it in GitHub Desktop.
Save rightfold/66b0397e1b1ad3e265e6 to your computer and use it in GitHub Desktop.
(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