Sometimes a plan wants to execute a series of steps until one step fails then move on to some finalization or clean up actions. This can be handled by writing a subplan and calling run_plan with _catch_errors => true but sometimes this is less readable.
Proposed solution: A catch_errors function that executes a block of code returning the final value or an Error if one was thrown.
Sometimes a plan wants to execute a series of steps until one step fails then move on to some finalization or clean up actions. This can be handled by writing a subplan and calling {{run_plan}} with {{_catch_errors => true}} but sometimes this is less readable.
Proposed solution: A catch_errors function that executes a block of code returning the final value or an Error if one was thrown.
Sometimes a plan wants to execute a series of steps until one step fails then move on to some finalization or clean up actions. This can be handled by writing a subplan and calling {{run_plan}} with {{_catch_errors => true}} but sometimes this is less readable.
Proposed solution: A catch_errors function that executes a block of code returning the final value or an Error if one was thrown. {noformat} $result_or_error = catch_errors([kind1, kind2]) ||{ run_task(task1) run_task(task2) run_task(task3) } query_result_or_error = catch(errors) ||{
Sometimes a plan wants to execute a series of steps until one step fails then move on to some finalization or clean up actions. This can be handled by writing a subplan and calling {{run_plan}} with {{_catch_errors => true}} but sometimes this is less readable.
Proposed solution: A catch_errors function that executes a block of code returning the final value or an Error if one was thrown.
* A `return` or `break` statement in a catch_errors block should break/return from the block not from the plan. Note: We should have a consistent way of catching returns in lambdas in Puppet - Alex will talk to Henrik about it.
Sometimes a plan wants to execute a series of steps until one step fails then move on to some finalization or clean up actions. This can be handled by writing a subplan and calling {{run_plan}} with {{_catch_errors => true}} but sometimes this is less readable.
{{catch_errors}} functions accept a list of types of errors to catch and then a block of code to run where if it errors the plan will continue executing. You cannot specify what to do when an error is raised.
Proposed solution: A catch_errors function that executes a block of code returning the final value or an Error if one was thrown. * A `return` or `break` statement in a catch_errors block should break/return from the block not from the plan. Note: We should have a consistent way of catching returns in lambdas in Puppet - Alex will talk to Henrik about it.
Sometimes a plan wants to execute a series of steps until one step fails then move on to some finalization or clean up actions. This can be handled by writing a subplan and calling {{run_plan}} with {{_catch_errors => true}} but sometimes this is less readable. {{catch_errors}} functions accept a list of types of errors to catch and then a block of code to run where if it errors the plan will continue executing. You cannot specify what to do when an error is raised.
Proposed solution: A catch_errors function that executes a block of code returning the final value or an Error if one was thrown.
* If the result was an error then that will be returned from the block or the result will be returned from the block.
* A `return` or `break` statement in a catch_errors block should break/return from the block not from the plan. Note: We should have a consistent way of catching returns in lambdas in Puppet - Alex will talk to Henrik about it.
* We should document using this with {{case}} to create more reasonable error-handling, where case looks at the result and acts on different types of errors.
Sometimes a plan wants to execute a series of steps until one step fails then move on to some finalization or clean up actions. This can be handled by writing a subplan and calling {{run_plan}} with {{_catch_errors => true}} but sometimes this is less readable. {{catch_errors}} functions accept a list of types of errors to catch and then a block of code to run where if it errors the plan will continue executing. You cannot specify what to do when an error is raised. Proposed solution: A catch_errors function that executes a block of code returning the final value or an Error if one was thrown. *
If the result was an error then that will be returned from the block * A `return` or `break` statement in a catch_errors block should break/return from the block not from the plan. Note: We should have a consistent way of catching returns in lambdas in Puppet - Alex will talk to Henrik about it.
* We should document using this with {{case}} to create more reasonable error-handling, where case looks at the result and acts on different types of errors. {noformat} $result_or_error = catch_errors([kind1, kind2]) ||{ run_task(task1) run_task(task2) run_task(task3) }
Sometimes a plan wants to execute a series of steps until one step fails then move on to some finalization or clean up actions. This can be handled by writing a subplan and calling {{run_plan}} with {{_catch_errors => true}} but sometimes this is less readable. {{catch_errors}} functions accept a list of types of errors to catch and then a block of code to run where if it errors the plan will continue executing. You cannot specify what to do when an error is raised.
Proposed solution: A catch_errors function that executes a block of code returning the final value or an Error if one was thrown.
* If the result was an error then that is raised in the block it will be returned from the block or, otherwise the result will be returned from the block.
* A `return` or `break` statement in a catch_errors block should break/return from the block not from the plan. Note: We should have a consistent way of catching returns in lambdas in Puppet - Alex will talk to Henrik about it. * We should document using this with {{case}} to create more reasonable error-handling, where case looks at the result and acts on different types of errors.
Sometimes a plan wants to execute a series of steps until one step fails then move on to some finalization or clean up actions. This can be handled by writing a subplan and calling {{run_plan}} with {{_catch_errors => true}} but sometimes this is less readable. {{catch_errors}} functions accept a list of types of errors to catch and then a block of code to run where if it errors the plan will continue executing. You cannot specify what to do when an error is raised.
Proposed solution: A catch_errors function that executes a block of code returning the final value or an Error if one was thrown.
* If an error is raised in the block it will be returned from the block, otherwise the result will be returned. * A ` {{return`}} or ` {{break`}} statement in a catch_errors block should break/return from the block not from the plan. Note: We should have a consistent way of catching returns in lambdas in Puppet - Alex will talk to Henrik about it.
* We should document using this with {{case}} to create more reasonable error-handling, where case looks at the result and acts on different types of errors.
Sometimes a plan wants to execute a series of steps until one step fails then move on to some finalization or clean up actions. This can be handled by writing a subplan and calling {{run_plan}} with {{_catch_errors => true}} but sometimes this is less readable. {{catch_errors}} functions accept a list of types of errors to catch and then a block of code to run where if it errors the plan will continue executing. You cannot specify what to do when an error is raised.
Proposed solution: A catch_errors function that executes a block of code returning the final value or an Error if one was thrown. * If an error is raised in the block it will be returned from the block, otherwise the result will be returned.
* A {{return}} or {{break}} statement in a catch_errors block should break/return from the block not from the plan. Note: We should have a consistent way of catching returns in lambdas in Puppet behave 'normally' - Alex will talk to Henrik about it. with no special handling
* We should document using this with {{case}} to create more reasonable error-handling, where case looks at the result and acts on different types of errors.
A new plan function catch_errors was added that accepts a list of types of errors to catch and a block of code to run where if it errors the plan will continue executing.