Class: OFlow::Actors::ErrorHandler

Inherits:
OFlow::Actor show all
Defined in:
lib/oflow/actors/errorhandler.rb

Overview

The default error handler.

Instance Attribute Summary

Attributes inherited from OFlow::Actor

#task

Instance Method Summary collapse

Methods inherited from OFlow::Actor

#busy?, #inputs, #options, #outputs, #set_option

Constructor Details

#initialize(task, options = {}) ⇒ ErrorHandler

Returns a new instance of ErrorHandler.



8
9
10
# File 'lib/oflow/actors/errorhandler.rb', line 8

def initialize(task, options={})
  super
end

Instance Method Details

#perform(op, box) ⇒ Object

Open the box, form a reasonable message, then log that message.

Parameters:

  • op (Symbol)

    ignores

  • box (Box)

    data associated with the error



15
16
17
18
19
20
21
22
23
# File 'lib/oflow/actors/errorhandler.rb', line 15

def perform(op, box)
  contents = box.contents
  return task.error(contents.to_s) unless contents.is_a?(Array)
  e, where = contents
  task.error(e.to_s) unless e.is_a?(Exception)
  msg = ["#{e.class}: #{e.message}"]
  e.backtrace.each { |line| msg << ('    ' + line) }
  task.log_msg(:error, msg.join("\n"), where)
end

#with_own_threadObject

Handle error immediately.



26
27
28
# File 'lib/oflow/actors/errorhandler.rb', line 26

def with_own_thread()
  false
end