Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Another implementation of defexception https://github.com/redplanetlabs/defexception using JiSE
(require '[jise.core :refer [defclass]])
(defmacro defexception [ex-name]
`(do
^:public
(defclass ~ex-name [clojure.lang.ExceptionInfo]
^:public
(defm ~ex-name [^String msg# ^clojure.lang.IPersistentMap map#]
(super msg# map#))
^:public
(defm ~ex-name [^String msg# ^clojure.lang.IPersistentMap map# ^Throwable cause#]
(super msg# map# cause#)))
(defn ~(symbol (str '-> ex-name))
([] (new ~ex-name nil {} nil))
([msg-o-data#]
(if (map? msg-o-data#)
(new ~ex-name nil msg-o-data# nil)
(new ~ex-name msg-o-data# {} nil)))
([msg# map#]
(new ~ex-name msg# map# nil))
([msg# map# cause#]
(new ~ex-name msg# map# cause#)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.