Exception: ResourceSpace::Error
- Inherits:
-
StandardError
- Object
- StandardError
- ResourceSpace::Error
- Defined in:
- lib/resourcespace/errors.rb
Overview
Base error class for all ResourceSpace errors
Direct Known Subclasses
AuthenticationError, AuthorizationError, ClientError, ConfigurationError, ConflictError, NetworkError, NotFoundError, ParseError, QuotaExceededError, RateLimitError, ServerError, TimeoutError, UploadError, ValidationError
Instance Attribute Summary collapse
-
#data ⇒ Hash?
readonly
Additional error data.
-
#response_body ⇒ String?
readonly
Response body if applicable.
-
#status_code ⇒ Integer?
readonly
HTTP status code if applicable.
Instance Method Summary collapse
-
#initialize(message = nil, data: nil, status_code: nil, response_body: nil) ⇒ Error
constructor
Initialize a new error.
-
#to_h ⇒ Hash
Convert error to a hash representation.
Constructor Details
#initialize(message = nil, data: nil, status_code: nil, response_body: nil) ⇒ Error
Initialize a new error
21 22 23 24 25 26 |
# File 'lib/resourcespace/errors.rb', line 21 def initialize( = nil, data: nil, status_code: nil, response_body: nil) @data = data @status_code = status_code @response_body = response_body super() end |
Instance Attribute Details
#data ⇒ Hash? (readonly)
Returns additional error data.
7 8 9 |
# File 'lib/resourcespace/errors.rb', line 7 def data @data end |
#response_body ⇒ String? (readonly)
Returns response body if applicable.
13 14 15 |
# File 'lib/resourcespace/errors.rb', line 13 def response_body @response_body end |
#status_code ⇒ Integer? (readonly)
Returns HTTP status code if applicable.
10 11 12 |
# File 'lib/resourcespace/errors.rb', line 10 def status_code @status_code end |
Instance Method Details
#to_h ⇒ Hash
Convert error to a hash representation
31 32 33 34 35 36 37 38 |
# File 'lib/resourcespace/errors.rb', line 31 def to_h { error: self.class.name, message: , status_code: status_code, data: data }.compact end |