class Nusii::NusiiError
Attributes
body[R]
reason_phrase[R]
status[R]
Public Class Methods
error_for(status)
click to toggle source
# File lib/nusii/nusii_error.rb, line 20 def self.error_for status case status when 400 then BadRequestError when 401 then UnauthorizedError when 403 then ForbiddenError when 404 then NotFoundError when 405 then MethodNotAllowedError when 406 then NotAcceptableError when 410 then GoneError when 429 then TooManyRequestsError when 500 then IntervalServerError when 503 then ServiceUnavailableError else NusiiError end end
new(status, body, reason_phrase)
click to toggle source
# File lib/nusii/nusii_error.rb, line 5 def initialize status, body, reason_phrase @status = status @body = body @reason_phrase = reason_phrase end
Public Instance Methods
message()
click to toggle source
# File lib/nusii/nusii_error.rb, line 16 def message @message ||= body.presence || reason_phrase.presence end
to_s()
click to toggle source
# File lib/nusii/nusii_error.rb, line 11 def to_s message_text = message.present? ? "\nMessage: #{message}" : '' "Status: #{status}#{message_text}" end