Exception: Mollie::RequestError

Inherits:
Exception
  • Object
show all
Defined in:
lib/mollie/exception.rb

Direct Known Subclasses

ResourceNotFoundError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, response = nil) ⇒ RequestError

Returns a new instance of RequestError.



8
9
10
11
12
13
14
15
# File 'lib/mollie/exception.rb', line 8

def initialize(error, response = nil)
  exception.status = error['status']
  exception.title  = error['title']
  exception.detail = error['detail']
  exception.field  = error['field']
  exception.links  = error['_links']
  self.response = response
end

Instance Attribute Details

#detail ⇒ Object

Returns the value of attribute detail.



6
7
8
# File 'lib/mollie/exception.rb', line 6

def detail
  @detail
end

#field ⇒ Object

Returns the value of attribute field.



6
7
8
# File 'lib/mollie/exception.rb', line 6

def field
  @field
end

Returns the value of attribute links.



6
7
8
# File 'lib/mollie/exception.rb', line 6

def links
  @links
end

#status ⇒ Object

Returns the value of attribute status.



6
7
8
# File 'lib/mollie/exception.rb', line 6

def status
  @status
end

#title ⇒ Object

Returns the value of attribute title.



6
7
8
# File 'lib/mollie/exception.rb', line 6

def title
  @title
end

Instance Method Details

#http_body ⇒ Object



25
26
27
# File 'lib/mollie/exception.rb', line 25

def http_body
  response.body if response
end

#http_headers ⇒ Object



21
22
23
# File 'lib/mollie/exception.rb', line 21

def http_headers
  response.to_hash if response
end

#to_s ⇒ Object



17
18
19
# File 'lib/mollie/exception.rb', line 17

def to_s
  "#{status} #{title}: #{detail}"
end