File tree 4 files changed +15
-21
lines changed
4 files changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,8 @@ Add the following dependency to your `project.clj`:<br>
75
75
(->> (?do-some-more-stuff )
76
76
(a/<! )
77
77
(println " success" ))
78
- (catch #?(:clj clojure.lang.ExceptionInfo
79
- :cljs ExceptionInfo ) e
78
+ (catch #?(:clj Throwable
79
+ :cljs :default ) e
80
80
(println " there is an error" e)))))
81
81
```
82
82
Original file line number Diff line number Diff line change 23
23
24
24
25
25
(defn chan?
26
- " Checks `x` of type channel (`clojure.core.async.impl.channels/ManyToManyChannel` / `cljs.core.async.impl.channels/ManyToManyChannel`)."
27
26
[x]
28
27
(instance? ManyToManyChannel x))
29
28
39
38
40
39
#?(:clj
41
40
(defmacro go
42
- " Like `core.async/go` but carries thrown exception as result."
41
+ " Like `core.async/go` but carries thrown error / exception as result."
43
42
[& body]
44
43
(if (:ns &env)
45
44
`(cljs.core.async/go
59
58
60
59
#?(:clj
61
60
(defmacro go-loop
62
- " Like `core.async/go-loop` but carries thrown exception as result."
61
+ " Like `core.async/go-loop` but carries thrown error / exception as result."
63
62
[bindings & body]
64
63
`(jtk-dvlp.async/go
65
64
(loop ~bindings
66
65
~@body))))
67
66
68
67
#?(:clj
69
68
(defmacro <!
70
- " Like `core.async/<!` but tests taken val instance of exception, if so throws it."
69
+ " Like `core.async/<!` but tests taken val of error / exception, if so throws it."
71
70
[?exp]
72
71
(if (:ns &env)
73
72
`(let [v# (cljs.core.async/<! ~?exp)]
89
88
v#))))
90
89
91
90
(defn map
92
- " Like `core.async/map` but carries thrown exception as result."
91
+ " Like `core.async/map` but carries thrown error / exception as result."
93
92
[f chs]
94
93
(async/map
95
94
(fn [& args]
114
113
chs))
115
114
116
115
(defn reduce
117
- " Like `core.async/reduce` but carries thrown exception as result."
116
+ " Like `core.async/reduce` but carries thrown error / exception as result."
118
117
[f init ch]
119
118
(async/reduce
120
119
(fn [accu v]
139
138
init ch))
140
139
141
140
(defn into
142
- " Like `core.async/into` but carries thrown exception as result."
141
+ " Like `core.async/into` but carries thrown error / exception as result."
143
142
[coll ch]
144
143
(reduce conj coll ch))
Original file line number Diff line number Diff line change 36
36
closing the channel! Otherwise channel will be closed after first put
37
37
(resolve or reject).
38
38
39
- If calling `exp` fails an `ExceptionInfo` will be put onto the
39
+ If calling `exp` fails an error / exception will be put onto the
40
40
new created channel with fail information. The channel will be
41
41
closed then.
42
42
64
64
(<cb!)
65
65
(println))
66
66
67
- (catch clojure.lang.ExceptionInfo e
67
+ (catch Throwable e
68
68
(println e)))))
69
69
```"
70
70
Original file line number Diff line number Diff line change 11
11
:cljs
12
12
(:require
13
13
[cljs.core.async :as async]
14
- [jtk-dvlp.async]))
15
-
16
- #? (:clj
17
- (:import
18
- [clojure.lang ExceptionInfo])))
14
+ [jtk-dvlp.async])))
19
15
20
16
21
17
(defn p->c
60
56
61
57
(defn c->p
62
58
" Creates a promise and resolves it with the val of channel `c`
63
- taken by `<!`, excepted val is an instance of `ExceptionInfo` rejects the
64
- promise. Closes the channel after took val."
59
+ taken by `<!` or rejects it on error / exception. Closes the channel after took val."
65
60
[c]
66
61
(create-promise
67
62
(fn [resolve reject]
97
92
c)))
98
93
99
94
(defn ->promise-chan
100
- " Ensure given channel `c` to be a `promise-chan` via
101
- `pipe` it into a new `promise-chan`. See `core.async/promise-chan`
102
- for more infos. Auto close channel `c`."
95
+ " Ensure given channel `c` to be a `promise-chan`.
96
+ See `core.async/promise-chan` for more infos.
97
+ Auto closes channel `c`."
103
98
[c]
104
99
(let [p (async/promise-chan )]
105
100
(async/take!
You can’t perform that action at this time.
0 commit comments