Exception: AuxiliaryRails::Application::Error Abstract
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- AuxiliaryRails::Application::Error
- Defined in:
- lib/auxiliary_rails/application/error.rb
Overview
This class is abstract.
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#exc ⇒ Object
Returns the value of attribute exc.
-
#severity ⇒ Object
Returns the value of attribute severity.
Class Method Summary collapse
- .i18n_scope ⇒ Object
-
.wrap(exc, context: {}, severity: nil) ⇒ self
Wraps exception into a new ApplicationError object.
Instance Method Summary collapse
- #default_context ⇒ Object
- #default_severity ⇒ Object
- #friendly_message ⇒ Object
-
#initialize(message = nil, context: {}, exc: nil, severity: nil) ⇒ Error
constructor
A new instance of Error.
- #report ⇒ Object
Constructor Details
#initialize(message = nil, context: {}, exc: nil, severity: nil) ⇒ Error
Returns a new instance of Error.
19 20 21 22 23 24 25 |
# File 'lib/auxiliary_rails/application/error.rb', line 19 def initialize( = nil, context: {}, exc: nil, severity: nil) super() self.context = default_context.merge(context || {}) self.exc = exc self.severity = severity&.to_sym || default_severity end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
5 6 7 |
# File 'lib/auxiliary_rails/application/error.rb', line 5 def context @context end |
#exc ⇒ Object
Returns the value of attribute exc.
6 7 8 |
# File 'lib/auxiliary_rails/application/error.rb', line 6 def exc @exc end |
#severity ⇒ Object
Returns the value of attribute severity.
6 7 8 |
# File 'lib/auxiliary_rails/application/error.rb', line 6 def severity @severity end |
Class Method Details
.i18n_scope ⇒ Object
9 10 11 |
# File 'lib/auxiliary_rails/application/error.rb', line 9 def i18n_scope "errors.#{name.underscore}" end |
.wrap(exc, context: {}, severity: nil) ⇒ self
Returns Wraps exception into a new ApplicationError object.
14 15 16 |
# File 'lib/auxiliary_rails/application/error.rb', line 14 def wrap(exc, context: {}, severity: nil) new(exc., context: context, exc: exc, severity: severity) end |
Instance Method Details
#default_context ⇒ Object
27 28 29 |
# File 'lib/auxiliary_rails/application/error.rb', line 27 def default_context {} end |
#default_severity ⇒ Object
31 32 33 |
# File 'lib/auxiliary_rails/application/error.rb', line 31 def default_severity :error end |
#friendly_message ⇒ Object
35 36 37 38 39 |
# File 'lib/auxiliary_rails/application/error.rb', line 35 def I18n.t(:default, scope: self.class.i18n_scope, default: 'We are sorry, but something went wrong.') end |
#report ⇒ Object
41 42 43 |
# File 'lib/auxiliary_rails/application/error.rb', line 41 def report raise NotImplementedError end |