Exception: Boxr::BoxrError
- Inherits:
-
StandardError
- Object
- StandardError
- Boxr::BoxrError
- Defined in:
- lib/boxr/errors.rb
Instance Attribute Summary collapse
-
#box_message ⇒ Object
readonly
Returns the value of attribute box_message.
-
#boxr_message ⇒ Object
readonly
Returns the value of attribute boxr_message.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#help_uri ⇒ Object
readonly
Returns the value of attribute help_uri.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(status: nil, body: nil, header: nil, boxr_message: nil) ⇒ BoxrError
constructor
A new instance of BoxrError.
- #message ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(status: nil, body: nil, header: nil, boxr_message: nil) ⇒ BoxrError
Returns a new instance of BoxrError.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/boxr/errors.rb', line 7 def initialize(status: nil, body: nil, header: nil, boxr_message: nil) @status = status @response_body = body @header = header @boxr_message = if(body) begin body_json = JSON.load(body) if body_json @type = body_json["type"] @box_status = body_json["status"] @code = body_json["code"] @help_uri = body_json["help_uri"] @box_message = body_json["message"] @request_id = body_json["request_id"] end rescue end end end |
Instance Attribute Details
#box_message ⇒ Object (readonly)
Returns the value of attribute box_message.
5 6 7 |
# File 'lib/boxr/errors.rb', line 5 def @box_message end |
#boxr_message ⇒ Object (readonly)
Returns the value of attribute boxr_message.
5 6 7 |
# File 'lib/boxr/errors.rb', line 5 def @boxr_message end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/boxr/errors.rb', line 5 def code @code end |
#help_uri ⇒ Object (readonly)
Returns the value of attribute help_uri.
5 6 7 |
# File 'lib/boxr/errors.rb', line 5 def help_uri @help_uri end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
5 6 7 |
# File 'lib/boxr/errors.rb', line 5 def request_id @request_id end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
5 6 7 |
# File 'lib/boxr/errors.rb', line 5 def response_body @response_body end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/boxr/errors.rb', line 5 def status @status end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/boxr/errors.rb', line 5 def type @type end |
Instance Method Details
#message ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/boxr/errors.rb', line 30 def auth_header = @header['WWW-Authenticate'][0] unless @header.nil? if(auth_header && auth_header != []) "#{@status}: #{auth_header}" elsif(@box_message) "#{@status}: #{@box_message}" elsif(@boxr_message) @boxr_message else "#{@status}: #{@response_body}" end end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/boxr/errors.rb', line 43 def to_s end |