Exception: ShipReal::Error

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

Overview

Any non-2xx response, carrying the RFC 9457 problem details the server sent.

Branch on #type rather than #status: the status says a request failed, the type says which failure it was, and only the second is stable enough to switch on.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, problem, url) ⇒ Error

Returns a new instance of Error.



43
44
45
46
47
48
49
50
51
# File 'lib/shipreal.rb', line 43

def initialize(status, problem, url)
  @status = status
  @problem = problem
  @url = url
  @type = problem && problem["type"]
  @title = problem && problem["title"]
  @detail = problem && problem["detail"]
  super(@detail || @title || "Request failed with #{status}")
end

Instance Attribute Details

#detailObject (readonly)

Returns the value of attribute detail.



41
42
43
# File 'lib/shipreal.rb', line 41

def detail
  @detail
end

#problemObject (readonly)

Returns the value of attribute problem.



41
42
43
# File 'lib/shipreal.rb', line 41

def problem
  @problem
end

#statusObject (readonly)

Returns the value of attribute status.



41
42
43
# File 'lib/shipreal.rb', line 41

def status
  @status
end

#titleObject (readonly)

Returns the value of attribute title.



41
42
43
# File 'lib/shipreal.rb', line 41

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



41
42
43
# File 'lib/shipreal.rb', line 41

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



41
42
43
# File 'lib/shipreal.rb', line 41

def url
  @url
end