Module: OFlow::HasErrorHandler

Included in:
Env, Flow, Task
Defined in:
lib/oflow/haserrorhandler.rb

Overview

Provides functionality to find an error handler Task which is how error are handled in the system. Each Flow or Task can have a different error handler. If a Flow does not have an error handler the error bubbles up to the next Flow until an error handler is found.

Instance Method Summary collapse

Instance Method Details

#error_handler=(t) ⇒ Object

Sets avaliable for handling errors.

Parameters:

  • t (Task|nil)

    Task for handling error or nil to unset



12
13
14
# File 'lib/oflow/haserrorhandler.rb', line 12

def error_handler=(t)
  @error_handler = t
end

#handle_error(e) ⇒ Object

Handles errors by putting a requestion on the error handler Task.

Parameters:

  • e (Exception)

    error to handle



18
19
20
21
22
23
24
25
26
# File 'lib/oflow/haserrorhandler.rb', line 18

def handle_error(e)
  handler = error_handler()
  if handler.nil?
    puts "** [#{full_name()}] #{e.class}: #{e.message}"
    e.backtrace.each { |line| puts "    #{line}" }
  else
    handler.receive(nil, Box.new([e, full_name()]))
  end
end