Exception: Commons::Errors::ErrorBase
- Inherits:
-
StandardError
- Object
- StandardError
- Commons::Errors::ErrorBase
- Includes:
- ActiveModel::Serialization
- Defined in:
- lib/commons/errors/error_base.rb
Direct Known Subclasses
BadRequest, Conflict, Forbidden, InternalServerError, MaintenanceMode, PaymentRequired, PreconditionFailed, ResourceNotFound, RouteNotFound, Unauthorized, UnprocessableEntity
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(message = nil, backtrace = nil, status: :internal_server_error, code: I18n.t('status_code.IER5000_internal_server_error.code'), title: I18n.t('status_code.IER5000_internal_server_error.title'), detail: I18n.t('status_code.IER5000_internal_server_error.detail'), meta: {}) ⇒ ErrorBase
constructor
A new instance of ErrorBase.
- #status ⇒ Object
-
#to_hash ⇒ Object
returns the error as its hash representation.
Constructor Details
#initialize(message = nil, backtrace = nil, status: :internal_server_error, code: I18n.t('status_code.IER5000_internal_server_error.code'), title: I18n.t('status_code.IER5000_internal_server_error.title'), detail: I18n.t('status_code.IER5000_internal_server_error.detail'), meta: {}) ⇒ ErrorBase
Returns a new instance of ErrorBase.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/commons/errors/error_base.rb', line 29 def initialize( = nil, backtrace = nil, status: :internal_server_error, code: I18n.t('status_code.IER5000_internal_server_error.code'), title: I18n.t('status_code.IER5000_internal_server_error.title'), detail: I18n.t('status_code.IER5000_internal_server_error.detail'), meta: {}) = @backtrace = backtrace @title = title @detail = detail @code = code @status = status = .merge!(message: ) unless .nil? || .nil? = nil if .blank? end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
27 28 29 |
# File 'lib/commons/errors/error_base.rb', line 27 def backtrace @backtrace end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
27 28 29 |
# File 'lib/commons/errors/error_base.rb', line 27 def code @code end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
27 28 29 |
# File 'lib/commons/errors/error_base.rb', line 27 def detail @detail end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
27 28 29 |
# File 'lib/commons/errors/error_base.rb', line 27 def end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
27 28 29 |
# File 'lib/commons/errors/error_base.rb', line 27 def end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
27 28 29 |
# File 'lib/commons/errors/error_base.rb', line 27 def title @title end |
Instance Method Details
#status ⇒ Object
59 60 61 |
# File 'lib/commons/errors/error_base.rb', line 59 def status Rack::Utils::SYMBOL_TO_STATUS_CODE[@status] end |
#to_hash ⇒ Object
returns the error as its hash representation
49 50 51 52 53 54 55 56 57 |
# File 'lib/commons/errors/error_base.rb', line 49 def to_hash { code: code, title: title, status: status, detail: detail, meta: } end |