Exception: ServiceError
- Inherits:
-
StandardError
- Object
- StandardError
- ServiceError
- Defined in:
- lib/service_error.rb
Instance Attribute Summary collapse
-
#error_obj ⇒ Object
readonly
Returns the value of attribute error_obj.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, error_obj = {}) ⇒ ServiceError
constructor
A new instance of ServiceError.
Constructor Details
#initialize(key, error_obj = {}) ⇒ ServiceError
15 16 17 18 19 20 |
# File 'lib/service_error.rb', line 15 def initialize(key, error_obj={}) @key = key = error_obj.delete(:error_message) || key @error_obj = error_obj super() end |
Instance Attribute Details
#error_obj ⇒ Object (readonly)
Returns the value of attribute error_obj.
3 4 5 |
# File 'lib/service_error.rb', line 3 def error_obj @error_obj end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
2 3 4 |
# File 'lib/service_error.rb', line 2 def key @key end |
Class Method Details
.generate_from_exception(exception, append_info = {}) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/service_error.rb', line 6 def generate_from_exception(exception, append_info={}) error_obj = {error_message: "#{exception.class.name}: #{exception.message}"} error_obj.merge!(append_info) service_err = new(:internal_error, error_obj) service_err.set_backtrace(exception.backtrace) service_err end |