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