class Roby::ExecutionEngine::PollBlockDefinition

@api private

Internal structure used to store a poll block definition provided to every or add_propagation_handler

@!macro poll_options

@option [Symbol] on_error if :raise (the default), pass exceptions
  to the caller. If :ignore, do nothing. If :disable, remove the
  poll block

Constants

ON_ERROR

Attributes

description[R]
handler[R]
on_error[R]

Public Class Methods

new(description, handler, on_error: :raise, late: false, once: false) click to toggle source
# File lib/roby/execution_engine.rb, line 221
def initialize(description, handler, on_error: :raise, late: false, once: false)
    if !PollBlockDefinition::ON_ERROR.include?(on_error.to_sym)
        raise ArgumentError, "invalid value '#{on_error} for the :on_error option. Accepted values are #{ON_ERROR.map(&:to_s).join(", ")}"
    end

    @description, @handler, @on_error, @late, @once =
        description, handler, on_error, late, once
    @disabled = false
end

Public Instance Methods

call(engine, *args) click to toggle source
# File lib/roby/execution_engine.rb, line 233
def call(engine, *args)
    handler.call(*args)
    true

rescue Exception => e
    if on_error == :raise
        engine.add_framework_error(e, description)
        return false
    elsif on_error == :disable
        engine.warn "propagation handler #{description} disabled because of the following error"
        Roby.log_exception_with_backtrace(e, engine, :warn)
        return false
    elsif on_error == :ignore
        engine.warn "ignored error from propagation handler #{description}"
        Roby.log_exception_with_backtrace(e, engine, :warn)
        return true
    end
end
id() click to toggle source
# File lib/roby/execution_engine.rb, line 219
def id; handler.object_id end
to_s() click to toggle source
# File lib/roby/execution_engine.rb, line 231
def to_s; "#<PollBlockDefinition: #{description} #{handler} on_error:#{on_error}>" end