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))]
(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]