Last active
August 29, 2015 14:10
Revisions
-
patrickgombert revised this gist
Dec 11, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ ; ; (def illegal-argument IllegalArgumentException) ; ; (try (catch illegal-argument _)) ; ; will raise the following exception: ; Unable to resolve classname: illegal-argument -
patrickgombert revised this gist
Dec 11, 2014 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,15 +3,15 @@ ; ; (def illegal-argument IllegalArgumentException) ; ; (try (catch c _)) ; ; will raise the following exception: ; Unable to resolve classname: illegal-argument (defmacro platform-try [& body] (let [c (reduce (fn [acc item] (if (and (seq? item) (= 'platform-catch (first item))) (rest item) acc)) nil body) @@ -20,8 +20,9 @@ catch-block (rest (rest c)) try-block (take-while (fn [item] (if (seq? item) (not= (first item) 'platform-catch) true)) body)] `(try ~@try-block (catch ~exception-class ~exception-var ~@catch-block)))) (playform-try (throw (IllegalArgumentException.)) (platform-catch illegal-argument _ nil)) ; => nil -
patrickgombert created this gist
Dec 5, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ ; try is a special form that seems to not allow def'd classes to be used ; for example: ; ; (def illegal-argument IllegalArgumentException) ; ; (try (catch illegal-argument _)) ; ; will raise the following exception: ; Unable to resolve classname: illegal-argument (defmacro platform-try [& body] (let [c (reduce (fn [acc item] (if (and (seq? item) (= :platform-catch (first item))) (rest item) acc)) nil body) exception-class (eval (first c)) exception-var (first (rest c)) catch-block (rest (rest c)) try-block (take-while (fn [item] (if (seq? item) (not= (first item) :platform-catch) true)) body)] `(try ~@try-block (catch ~exception-class ~exception-var ~@catch-block))))