Class: CircuitClient::ClientError
- Inherits:
-
Faraday::ClientError
- Object
- Faraday::ClientError
- CircuitClient::ClientError
- Defined in:
- lib/circuit_client/errors.rb
Instance Method Summary collapse
-
#initialize(ex, response = nil) ⇒ ClientError
constructor
A new instance of ClientError.
Constructor Details
#initialize(ex, response = nil) ⇒ ClientError
Returns a new instance of ClientError.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/circuit_client/errors.rb', line 5 def initialize(ex, response = nil) content_type = ex[:headers]['Content-Type'] if !content_type.nil? && content_type.match(/application\/json/) begin error = JSON.parse(ex[:body]) super("server response: #{error.to_json} (status: #{ex[:status]})") rescue JSON::ParserError super("server response with status #{ex[:status]} and malformed JSON") end else super(ex, response) end end |