class CircuitClient::ClientError

Public Class Methods

new(ex, response = nil) click to toggle source
Calls superclass method
# 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