Exception: JsonapiErrorsHandler::Errors::StandardError
- Inherits:
-
StandardError
- Object
- StandardError
- JsonapiErrorsHandler::Errors::StandardError
- Defined in:
- lib/jsonapi_errors_handler/errors/standard_error.rb
Overview
Handles serialization of Unexpected HTTP error (500 status code) It’s also a fallback for not mapped errors in the application.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title: nil, status: nil, detail: nil, message: nil, source: {}) ⇒ StandardError
constructor
A new instance of StandardError.
- #serializable_hash ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(title: nil, status: nil, detail: nil, message: nil, source: {}) ⇒ StandardError
Returns a new instance of StandardError.
11 12 13 14 15 16 17 18 19 |
# File 'lib/jsonapi_errors_handler/errors/standard_error.rb', line 11 def initialize( title: nil, status: nil, detail: nil, message: nil, source: {} ) @title = title || 'Something went wrong' @detail = detail || @detail ||= "We've encountered unexpected error, but our developers had been already notified about it" # rubocop:disable Metrics/LineLength @status = status || 500 @source = KeysStringifier.call(source) end |
Instance Attribute Details
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
38 39 40 |
# File 'lib/jsonapi_errors_handler/errors/standard_error.rb', line 38 def detail @detail end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
38 39 40 |
# File 'lib/jsonapi_errors_handler/errors/standard_error.rb', line 38 def source @source end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
38 39 40 |
# File 'lib/jsonapi_errors_handler/errors/standard_error.rb', line 38 def status @status end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
38 39 40 |
# File 'lib/jsonapi_errors_handler/errors/standard_error.rb', line 38 def title @title end |
Instance Method Details
#serializable_hash ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/jsonapi_errors_handler/errors/standard_error.rb', line 21 def serializable_hash { status: status.to_s, title: title, detail: detail, source: source } end |
#to_h ⇒ Object
30 31 32 |
# File 'lib/jsonapi_errors_handler/errors/standard_error.rb', line 30 def to_h serializable_hash end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/jsonapi_errors_handler/errors/standard_error.rb', line 34 def to_s serializable_hash.to_s end |