This commit is contained in:
Michiel Borkent 2022-12-29 15:25:18 +01:00
parent decf791000
commit a9faec4776

View file

@ -177,14 +177,17 @@
(let [id (get reply "id") (let [id (get reply "id")
id (bytes->string id) id (bytes->string id)
value* (find reply "value") value* (find reply "value")
value (some-> value* [exception value] (try (some->> value*
second second
bytes->string bytes->string
read-fn) read-fn
(vector nil))
(catch Exception e
[e nil]))
status (get reply "status") status (get reply "status")
status (set (map (comp keyword bytes->string) status)) status (set (map (comp keyword bytes->string) status))
error? (contains? status :error) error? (or exception (contains? status :error))
done? (or error? (contains? status :done)) done? (or error? exception (contains? status :done))
[ex-message ex-data] [ex-message ex-data]
(when error? (when error?
[(or (some-> (get reply "ex-message") [(or (some-> (get reply "ex-message")
@ -202,8 +205,9 @@
:vars (bencode->vars pod name-str v)})) :vars (bencode->vars pod name-str v)}))
chan (get @chans id) chan (get @chans id)
promise? (instance? clojure.lang.IPending chan) promise? (instance? clojure.lang.IPending chan)
exception (when (and promise? error?) exception (or exception
(ex-info ex-message ex-data)) (when (and promise? error?)
(ex-info ex-message ex-data)))
;; NOTE: if we need more fine-grained handlers, we will add ;; NOTE: if we need more fine-grained handlers, we will add
;; a :raw handler that will just get the bencode message's raw ;; a :raw handler that will just get the bencode message's raw
;; data ;; data