throw if eth-rpc returns error

This commit is contained in:
Martin Klepsch 2018-03-20 12:46:14 +01:00
parent 2eb2de2888
commit b833cee66d
No known key found for this signature in database
GPG Key ID: 1A35E702AD48A9F6

View File

@ -127,13 +127,17 @@
result (safe-read-str (:body response))]
(log/debug body "\n" result)
(if (= (:id result) request-id)
(:result result)
(do
(log/error "Geth returned an invalid json-rpc request ID,"
"ignoring response")
(when-let [error (:error result)]
(log/error "Method: " method ", error: " error))))))
(cond
;; Ignore any responses that have mismatching request ID
(not= (:id result) request-id)
(log/error "Geth returned an invalid json-rpc request ID, ignoring response")
;; If request ID matches but contains error, throw
(:error result)
(throw (ex-info "Error submitting transaction via eth-rpc" (:error result)))
:else
(:result result))))
(defn hex->big-integer
[hex]