Exception: Adyen::REST::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/adyen/rest/errors.rb

Overview

Exception class for error responses from the Adyen API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_body) ⇒ ResponseError



23
24
25
26
27
28
29
30
# File 'lib/adyen/rest/errors.rb', line 23

def initialize(response_body)
  if match = /\A(\w+)\s(\d+)\s(.*)\z/.match(response_body)
    @category, @code, @description = match[1], match[2].to_i, match[3]
    super("API request error: #{description} (code: #{code}/#{category})")
  else
    super("API request error: #{response_body}")
  end
end

Instance Attribute Details

#categoryString?



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/adyen/rest/errors.rb', line 20

class ResponseError < Adyen::REST::Error
  attr_accessor :category, :code, :description

  def initialize(response_body)
    if match = /\A(\w+)\s(\d+)\s(.*)\z/.match(response_body)
      @category, @code, @description = match[1], match[2].to_i, match[3]
      super("API request error: #{description} (code: #{code}/#{category})")
    else
      super("API request error: #{response_body}")
    end
  end
end

#codeInteger?



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/adyen/rest/errors.rb', line 20

class ResponseError < Adyen::REST::Error
  attr_accessor :category, :code, :description

  def initialize(response_body)
    if match = /\A(\w+)\s(\d+)\s(.*)\z/.match(response_body)
      @category, @code, @description = match[1], match[2].to_i, match[3]
      super("API request error: #{description} (code: #{code}/#{category})")
    else
      super("API request error: #{response_body}")
    end
  end
end

#descriptionString?



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/adyen/rest/errors.rb', line 20

class ResponseError < Adyen::REST::Error
  attr_accessor :category, :code, :description

  def initialize(response_body)
    if match = /\A(\w+)\s(\d+)\s(.*)\z/.match(response_body)
      @category, @code, @description = match[1], match[2].to_i, match[3]
      super("API request error: #{description} (code: #{code}/#{category})")
    else
      super("API request error: #{response_body}")
    end
  end
end