Exception: Firstclasspostcodes::ResponseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/firstclasspostcodes/response_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, type = nil) ⇒ ResponseError

Returns a new instance of ResponseError.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/firstclasspostcodes/response_error.rb', line 9

def initialize(obj, type = nil)
  if obj.is_a?(Hash)
    super(obj[:message])
    @doc_url = obj[:docUrl]
    @type = obj[:type]
    return
  end
  super(obj)
  @doc_url = "#{DOC_URL}/#{type}"
  @type = type
end

Instance Attribute Details

#doc_urlObject (readonly)

Returns the value of attribute doc_url.



7
8
9
# File 'lib/firstclasspostcodes/response_error.rb', line 7

def doc_url
  @doc_url
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/firstclasspostcodes/response_error.rb', line 7

def type
  @type
end

Instance Method Details

#messageObject



21
22
23
24
25
26
27
# File 'lib/firstclasspostcodes/response_error.rb', line 21

def message
  "    The following \"\#{type}\" error was encountered:\n      \#{super}\n    => See: \#{doc_url}\n  MSG\nend\n"