Thibault Jouan c4fc9828db Improve error reporting during recipe evaluation
* Report invalid action usages from tasks;
* Implement backtrace cleaning in CLI;
* Extract error class declarations in a new errors file;
* Replace raise with fail keyword in task DSL class.
2013-08-01 20:31:39 +00:00

25 lines
499 B
Ruby

module Producer
module Core
class Task
class DSL
def initialize(&block)
@block = block
end
def evaluate(env)
instance_eval &@block
rescue ConditionNotMetError
rescue NameError => e
raise TaskEvaluationError,
"invalid task action `#{e.name}'",
e.backtrace
end
def condition(&block)
fail ConditionNotMetError unless block.call
end
end
end
end
end