This repository was archived by the owner on Mar 20, 2020. It is now read-only.
File tree 3 files changed +28
-0
lines changed
3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,14 @@ When `throw` is not enough.
16
16
17
17
; ; Throw an ex-info exception.
18
18
(╯°□°╯︵oɟuᴉ {:some {:extra :data }})
19
+
20
+ ; ; Sometimes tables must be respected, and so they may be caught as well
21
+ (v°□°v
22
+ (/ 1 0 )
23
+ (┬─┬ ╯°_°╯ ArithmeticException
24
+ (log/error ┬─┬)
25
+ 0 ))
26
+
19
27
```
20
28
21
29
There's no artifact on Clojars¹ but it doesn't matter because you can simply
Original file line number Diff line number Diff line change 5
5
[throwable ]
6
6
(throw throwable ))
7
7
8
+ (defmacro v °□°v
9
+ [& body]
10
+ (loop [new-body `(try )
11
+ [current-form & forms] body]
12
+ (if current-form
13
+ (if (= (second current-form) '╯°_°╯)
14
+ (let [[old-first old-second old-third & others] current-form]
15
+ (recur (concat new-body (list `(catch ~old-third ~old-first ~@others)))
16
+ forms))
17
+ (recur (concat new-body `(~current-form))
18
+ forms))
19
+ new-body)))
20
+
8
21
(defn ╯°□°╯︵oɟuᴉ
9
22
" A shorthand for ╯°□°╯ with ex-info."
10
23
([map]
Original file line number Diff line number Diff line change 11
11
(is (thrown-with-msg?
12
12
Exception #"^╯°□°╯$"
13
13
(╯°□°╯︵oɟuᴉ {}))))
14
+
15
+ (deftest v °□°v-test
16
+ (is (= (v°□°v (/ 1 0 ) (┬─┬ ╯°_°╯ Exception " caught" ))
17
+ " caught" ))
18
+
19
+ (is (= (v°□°v (/ 1 0 ) (┬─┬ ╯°_°╯ Exception (type ┬─┬)))
20
+ java.lang.ArithmeticException)))
You can’t perform that action at this time.
0 commit comments