Exception: Moromi::Error::Default
- Inherits:
-
StandardError
- Object
- StandardError
- Moromi::Error::Default
- Defined in:
- lib/moromi/error/errors.rb
Direct Known Subclasses
AuthenticationFailed, NeedForceUpdate, NotFound, PermissionDenied, TooManyRequests, ValidationError
Constant Summary collapse
- DEFAULT_CODE =
0- DEFAULT_TITLE =
'moromi-error.an_error_has_occurred'- DEFAULT_ERRORS =
['moromi-error.an_error_has_occurred']
Instance Attribute Summary collapse
- #debug_message ⇒ String readonly
-
#detail_url ⇒ Object
Returns the value of attribute detail_url.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#log_severity ⇒ Object
readonly
Returns the value of attribute log_severity.
-
#original_exception ⇒ Object
Returns the value of attribute original_exception.
Class Method Summary collapse
Instance Method Summary collapse
- #cleaned_backtrace ⇒ Object
- #code ⇒ Object
- #error_title ⇒ Object
-
#initialize(code: nil, error_title: nil, errors: self.class::DEFAULT_ERRORS, message: nil, debug_message: nil, detail_url: nil, skip_logging: false, log_severity: Logger::Severity::ERROR) ⇒ Default
constructor
A new instance of Default.
- #skip_logging? ⇒ Boolean
Constructor Details
#initialize(code: nil, error_title: nil, errors: self.class::DEFAULT_ERRORS, message: nil, debug_message: nil, detail_url: nil, skip_logging: false, log_severity: Logger::Severity::ERROR) ⇒ Default
Returns a new instance of Default.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/moromi/error/errors.rb', line 22 def initialize(code: nil, error_title: nil, errors: self.class::DEFAULT_ERRORS, message: nil, debug_message: nil, detail_url: nil, skip_logging: false, log_severity: Logger::Severity::ERROR) super() @code = code @error_title = error_title @errors = errors @debug_message = if Moromi::Error.config.debug @detail_url = detail_url @skip_logging = skip_logging @log_severity = log_severity end |
Instance Attribute Details
#debug_message ⇒ String (readonly)
56 57 58 |
# File 'lib/moromi/error/errors.rb', line 56 def @debug_message end |
#detail_url ⇒ Object
Returns the value of attribute detail_url.
12 13 14 |
# File 'lib/moromi/error/errors.rb', line 12 def detail_url @detail_url end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/moromi/error/errors.rb', line 8 def errors @errors end |
#log_severity ⇒ Object (readonly)
Returns the value of attribute log_severity.
10 11 12 |
# File 'lib/moromi/error/errors.rb', line 10 def log_severity @log_severity end |
#original_exception ⇒ Object
Returns the value of attribute original_exception.
11 12 13 |
# File 'lib/moromi/error/errors.rb', line 11 def original_exception @original_exception end |
Class Method Details
.make(exception) ⇒ Moromi::Error::Default
35 36 37 38 39 40 41 |
# File 'lib/moromi/error/errors.rb', line 35 def self.make(exception) return exception if exception.is_a? ::Moromi::Error::Default new(debug_message: exception.try(:message) || '').tap do |e| e.original_exception = exception end end |
Instance Method Details
#cleaned_backtrace ⇒ Object
66 67 68 |
# File 'lib/moromi/error/errors.rb', line 66 def cleaned_backtrace ::Rails.backtrace_cleaner.clean(backtrace || []) end |
#code ⇒ Object
43 44 45 |
# File 'lib/moromi/error/errors.rb', line 43 def code @code || self.class::DEFAULT_CODE end |
#error_title ⇒ Object
51 52 53 |
# File 'lib/moromi/error/errors.rb', line 51 def error_title translate(@error_title || self.class::DEFAULT_TITLE) end |
#skip_logging? ⇒ Boolean
62 63 64 |
# File 'lib/moromi/error/errors.rb', line 62 def skip_logging? @skip_logging end |