Skip to content

Commit

Permalink
add nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
xuxiaohu committed Mar 11, 2022
1 parent 701873d commit 9921b91
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/substrate_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def ws_request(url, payload)
ws.on :close do |event|
ws = nil
end

ws.on :error do |event|
EM.stop
end
end

result
Expand Down Expand Up @@ -51,7 +55,9 @@ def request(method, params)
}

data = ws_request(@url, payload)
if data["error"]
if data.nil?
raise @url, payload.inspect, "url:#{@url}, payload: #{payload.inspect}, data: #{data.inspect}"
elsif data["error"]
raise RpcError, data["error"]
else
data["result"]
Expand Down

0 comments on commit 9921b91

Please sign in to comment.