Exception: Nusii::NusiiError
- Inherits:
-
StandardError
- Object
- StandardError
- Nusii::NusiiError
- Defined in:
- lib/nusii/nusii_error.rb
Direct Known Subclasses
BadRequestError, ForbiddenError, GoneError, IntervalServerError, MethodNotAllowedError, NotAcceptableError, NotFoundError, ServiceUnavailableError, TooManyRequestsError, UnauthorizedError
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#reason_phrase ⇒ Object
readonly
Returns the value of attribute reason_phrase.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status, body, reason_phrase) ⇒ NusiiError
constructor
A new instance of NusiiError.
- #message ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(status, body, reason_phrase) ⇒ NusiiError
Returns a new instance of NusiiError.
5 6 7 8 9 |
# File 'lib/nusii/nusii_error.rb', line 5 def initialize status, body, reason_phrase @status = status @body = body @reason_phrase = reason_phrase end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/nusii/nusii_error.rb', line 3 def body @body end |
#reason_phrase ⇒ Object (readonly)
Returns the value of attribute reason_phrase.
3 4 5 |
# File 'lib/nusii/nusii_error.rb', line 3 def reason_phrase @reason_phrase end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/nusii/nusii_error.rb', line 3 def status @status end |
Class Method Details
.error_for(status) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 |
Instance Method Details
#message ⇒ Object
16 17 18 |
# File 'lib/nusii/nusii_error.rb', line 16 def @message ||= body.presence || reason_phrase.presence end |
#to_s ⇒ Object
11 12 13 14 |
# File 'lib/nusii/nusii_error.rb', line 11 def to_s = .present? ? "\nMessage: #{}" : '' "Status: #{status}#{}" end |