Class: Bumbleworks::Process::ErrorRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/bumbleworks/process/error_record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(process_error) ⇒ ErrorRecord

The initializer takes a Ruote::ProcessError instance.



7
8
9
# File 'lib/bumbleworks/process/error_record.rb', line 7

def initialize(process_error)
  @process_error = process_error
end

Instance Attribute Details

#process_errorObject (readonly)

Returns the value of attribute process_error.



4
5
6
# File 'lib/bumbleworks/process/error_record.rb', line 4

def process_error
  @process_error
end

Instance Method Details

#backtraceObject

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.



43
44
45
# File 'lib/bumbleworks/process/error_record.rb', line 43

def backtrace
  @process_error.h['trace'].split(/\n/)
end

#error_class_nameObject

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.



35
36
37
# File 'lib/bumbleworks/process/error_record.rb', line 35

def error_class_name
  @process_error.h['class']
end

#feiObject

Returns the FlowExpressionId of the expression where this error occurred.



25
26
27
# File 'lib/bumbleworks/process/error_record.rb', line 25

def fei
  @process_error.fei
end

#messageObject

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.



53
54
55
56
# File 'lib/bumbleworks/process/error_record.rb', line 53

def message
  @message ||= @process_error.message.
    gsub(/\#\<#{error_class_name}: (.*)\>$/, '\1')
end

#reifyObject

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.



73
74
75
76
77
78
# File 'lib/bumbleworks/process/error_record.rb', line 73

def reify
  klass = Bumbleworks::Support.constantize(error_class_name)
  err = klass.new(message)
  err.set_backtrace(backtrace)
  err
end

#replayObject

Replays the error’s process at the point where the error occurred. Should only be called when the cause of the error has been fixed, since otherwise this will just cause the error to show up again.



14
15
16
# File 'lib/bumbleworks/process/error_record.rb', line 14

def replay
  Bumbleworks.dashboard.replay_at_error(@process_error)
end

#workitemObject

Returns the workitem at the position where this error occurred.



19
20
21
# File 'lib/bumbleworks/process/error_record.rb', line 19

def workitem
  @process_error.workitem
end