class Boxr::BoxrError
Attributes
box_message[R]
boxr_message[R]
code[R]
help_uri[R]
request_id[R]
response_body[R]
status[R]
type[R]
Public Class Methods
new(status: nil, body: nil, header: nil, boxr_message: nil)
click to toggle source
# 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 = 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
Public Instance Methods
message()
click to toggle source
# File lib/boxr/errors.rb, line 30 def message 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()
click to toggle source
# File lib/boxr/errors.rb, line 43 def to_s message end