Skip to content

Instantly share code, notes, and snippets.

@athos
Created August 24, 2019 00:31
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 athos/d55eeb0b64f6051e4bf3522970323466 to your computer and use it in GitHub Desktop.
Save athos/d55eeb0b64f6051e4bf3522970323466 to your computer and use it in GitHub Desktop.
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