Module: OFlow::HasErrorHandler
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
-
#error_handler ⇒ Task|nil
Returns an error handler Task by checking for an @error_handler variable, then looking for a Task with a base name of :error in itself or any of the containing Flows.
-
#error_handler=(t) ⇒ Object
Sets avaliable for handling errors.
-
#handle_error(e) ⇒ Object
Handles errors by putting a requestion on the error handler Task.
Instance Method Details
#error_handler ⇒ Task|nil
Returns an error handler Task by checking for an @error_handler variable, then looking for a Task with a base name of :error in itself or any of the containing Flows.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/oflow/haserrorhandler.rb', line 14 def error_handler() return @error_handler if instance_variable_defined?(:@error_handler) && !@error_handler.nil? if instance_variable_defined?(:@flow) if @flow.respond_to?(:find_task) eh = @flow.find_task(:error) return eh unless eh.nil? end if @flow.respond_to?(:error_handler) eh = @flow.error_handler() return eh unless eh.nil? end end nil end |
#error_handler=(t) ⇒ Object
Sets avaliable for handling errors.
31 32 33 |
# File 'lib/oflow/haserrorhandler.rb', line 31 def error_handler=(t) @error_handler = t end |
#handle_error(e) ⇒ Object
Handles errors by putting a requestion on the error handler Task.
37 38 39 40 41 42 43 44 45 |
# File 'lib/oflow/haserrorhandler.rb', line 37 def handle_error(e) handler = error_handler() unless handler.nil? handler.receive(nil, Box.new([e, full_name()])) else puts "** [#{full_name()}] #{e.class}: #{e.}" e.backtrace.each { |line| puts " #{line}" } end end |