Sha256: cf95a51cc13fdccea6d43e854f9bdf730f5fe20e3ab4ff30eb6d169b07bb684b
Contents?: true
Size: 565 Bytes
Versions: 1
Compression:
Stored size: 565 Bytes
Contents
module Uatu module Response class RaiseMarvelError < Faraday::Response::Middleware def on_complete(env) status = env[:status] body = env[:body] headers = env[:response_headers] parsed_body = JSON.parse(body) code = parsed_body['code'] message = parsed_body['message'] || parsed_body['status'] unless code.to_i == 200 raise Uatu::Error::ClientError.new "- Error code: #{code}\n- Message: #{message}\n ", {body: body, headers: headers} end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
uatu-marvel-0.1.0 | lib/uatu/response.rb |