Exception: Apia::ErrorExceptionError
- Inherits:
-
RuntimeError
- Object
- StandardError
- StandardError
- RuntimeError
- Apia::ErrorExceptionError
- Defined in:
- lib/apia/errors/error_exception_error.rb
Overview
This is the error exception that must be raised when you wish to raise an error. It should be initialized with the Apia::Error class that you wish to raise.
Instance Attribute Summary collapse
-
#error_class ⇒ Object
readonly
Returns the value of attribute error_class.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #hash ⇒ Object
- #http_status ⇒ Object
-
#initialize(error_class, fields = {}) ⇒ ErrorExceptionError
constructor
A new instance of ErrorExceptionError.
Constructor Details
#initialize(error_class, fields = {}) ⇒ ErrorExceptionError
Returns a new instance of ErrorExceptionError.
14 15 16 17 |
# File 'lib/apia/errors/error_exception_error.rb', line 14 def initialize(error_class, fields = {}) @error_class = error_class @fields = fields end |
Instance Attribute Details
#error_class ⇒ Object (readonly)
Returns the value of attribute error_class.
11 12 13 |
# File 'lib/apia/errors/error_exception_error.rb', line 11 def error_class @error_class end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
12 13 14 |
# File 'lib/apia/errors/error_exception_error.rb', line 12 def fields @fields end |
Instance Method Details
#hash ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/apia/errors/error_exception_error.rb', line 23 def hash { code: @error_class.definition.code, description: @error_class.definition.description, detail: @error_class.definition.fields.generate_hash(@fields) } end |
#http_status ⇒ Object
19 20 21 |
# File 'lib/apia/errors/error_exception_error.rb', line 19 def http_status @error_class.definition.http_status || 500 end |