class EmpireAvenue::Error::ClientError
Raised when EmpireAvenue
returns a 4xx HTTP status code or there’s an error in Faraday
Public Class Methods
from_response(response={})
click to toggle source
Create a new error from an HTTP environment
@param response [Hash] @return [EmpireAvenue::Error]
# File lib/empireavenue/error/client_error.rb, line 12 def self.from_response(response={}) new(parse_error(response[:body]), response[:response_headers]) end
Private Class Methods
parse_error(body)
click to toggle source
# File lib/empireavenue/error/client_error.rb, line 18 def self.parse_error(body) if body.nil? '' elsif body[:error] body[:error] elsif body[:errors] first = Array(body[:errors]).first if first.kind_of?(Hash) first[:message].chomp else first.chomp end end end