lib/promisepay/error.rb
# Returns the appropriate Promisepay::Error subclass based on status
#
# @param [Faraday::Response] response Faraday HTTP response
# @return [Promisepay::Error]
Returns the appropriate Promisepay::Error subclass based on status
Returns the appropriate Promisepay :: Error subclass based on status
def build_error_message
      return nil if @response.nil? || @response.body.nil?
      case @errors_format
      when 'raw'
        @response.body
      else
        json_response = JSON.parse(@response.body)
        message = ''
        message << json_response['message'] if json_response.key?('message')
        if json_response.key?('errors')
          message << json_response['errors'].map{|attribute, content| "#{attribute}: #{content}"}.join(", ")
        end
        message
      end
    end
def build_error_message return nil if @response . nil? || @response . body . nil? case @errors_format when 'raw' @response . body else json_response = JSON . parse ( @response . body ) message = '' message << json_response [ 'message' ] if json_response . key? ( 'message' ) if json_response . key? ( 'errors' ) message << json_response [ 'errors' ] . map { | attribute , content | "#{attribute}: #{content}" } . join ( ", " ) end message end end
Returns the appropriate Promisepay::Error subclass based on status
Returns the appropriate Promisepay :: Error subclass based on status
None
Promisepay::Error
<not_specific>
response Faraday HTTP response
response Faraday HTTP response