Sha256: 541dd3b09edaf08571ca2f08b2cbbce8c082ed1940a16950f0a28d6eb587995b

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module Pione
  module RuleEngine
    # Exception class for rule execution failure.
    class RuleExecutionError < StandardError
      def initialize(handler)
        @handler = handler
      end

      def message
        "Execution error when handling the rule '%s': inputs=%s, output=%s, param_set=%s" % [
          @handler.rule_name,
          @handler.inputs,
          @handler.outputs,
          @handler.param_set
        ]
      end
    end

    class ActionError < RuleExecutionError
      def initialize(handler, digest, report)
        super(handler)
        @digest = digest
        @report = report
      end

      def message
        "Action rule %s has errored:\n%s" % [@digest, @report]
      end
    end

    class InvalidOutputError < RuleExecutionError
      def initialize(handler, outputs)
        super(handler)
        @outputs = outputs
      end

      def message
        args = [@handler.rule_name, @handler.package_id, @outputs]
        "Outputs of rule '%s' in package &%s are invalid: %s" % args
      end
    end

    class UnknownRule < RuleExecutionError; end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pione-0.4.2 lib/pione/rule-engine/engine-exception.rb
pione-0.4.1 lib/pione/rule-engine/engine-exception.rb
pione-0.4.0 lib/pione/rule-engine/engine-exception.rb