Merge pull request #364 from martinklepsch/throw-if-no-gas

throw if eth-rpc returns error
This commit is contained in:
Tetiana Churikova 2018-03-22 17:50:55 +02:00 committed by GitHub
commit bf639c17b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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