Class: Bumbleworks::Process::ErrorRecord
- Inherits:
-
Object
- Object
- Bumbleworks::Process::ErrorRecord
- Defined in:
- lib/bumbleworks/process/error_record.rb
Instance Method Summary collapse
-
#backtrace ⇒ Object
Returns the original error’s backtrace.
-
#error_class_name ⇒ Object
Be aware that this class may not exist in the current binding when you instantiate the ErrorRecord; if it does not, calling #reify will throw an exception.
-
#fei ⇒ Object
Returns the FlowExpressionId of the expression where this error occurred.
-
#initialize(process_error) ⇒ ErrorRecord
constructor
The initializer takes a Ruote::ProcessError instance.
-
#message ⇒ Object
Returns the original error message.
-
#reify ⇒ Object
Re-instantiates the original exception.
Constructor Details
#initialize(process_error) ⇒ ErrorRecord
The initializer takes a Ruote::ProcessError instance.
5 6 7 |
# File 'lib/bumbleworks/process/error_record.rb', line 5 def initialize(process_error) @process_error = process_error end |
Instance Method Details
#backtrace ⇒ Object
Returns the original error’s backtrace.
The original backtrace will be returned in standard backtrace format: an array of strings with paths and line numbers.
29 30 31 |
# File 'lib/bumbleworks/process/error_record.rb', line 29 def backtrace @process_error.h['trace'].split(/\n/) end |
#error_class_name ⇒ Object
Be aware that this class may not exist in the current binding when you instantiate the ErrorRecord; if it does not, calling #reify will throw an exception.
21 22 23 |
# File 'lib/bumbleworks/process/error_record.rb', line 21 def error_class_name @process_error.h['class'] end |
#fei ⇒ Object
Returns the FlowExpressionId of the expression where this error occurred.
11 12 13 |
# File 'lib/bumbleworks/process/error_record.rb', line 11 def fei @process_error.fei end |
#message ⇒ Object
Returns the original error message.
Ruote’s error logging has a strange issue; the message recorded and returned via the Ruote::ProcessError instance is the full #inspect of the error. This method strips away the resulting cruft (if it exists) and leaves behind just the message itself.
39 40 41 42 |
# File 'lib/bumbleworks/process/error_record.rb', line 39 def @message ||= @process_error.. gsub(/\#\<#{error_class_name}: (.*)\>$/, '\1') end |
#reify ⇒ Object
Re-instantiates the original exception.
If you wish to re-create the actual exception that was raised during process execution, this method will attempt to return an instance of the error class, with the message and backtrace restored.
In order for this to work, the error class itself must be a defined constant in the current binding; if it’s not, you’ll get an exception. Be cognizant of this caveat if you choose to use this feature; Bumbleworks makes no attempt to protect you.
This is not because Bumbleworks doesn’t love you. It just wants you to spread your wings, and the only way to truly experience flight is to first taste the ground.
59 60 61 62 63 64 |
# File 'lib/bumbleworks/process/error_record.rb', line 59 def reify klass = Bumbleworks::Support.constantize(error_class_name) err = klass.new() err.set_backtrace(backtrace) err end |