Created
August 24, 2019 00:31
-
-
Save athos/d55eeb0b64f6051e4bf3522970323466 to your computer and use it in GitHub Desktop.
Another implementation of defexception https://github.com/redplanetlabs/defexception using JiSE
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
(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