Jira (BOLT-1316) The plan language should have a catch_errors functions

24 views
Skip to first unread message

Alex Dreyer (JIRA)

unread,
May 16, 2019, 5:23:04 PM5/16/19
to puppe...@googlegroups.com
Alex Dreyer created an issue
 
Puppet Task Runner / New Feature BOLT-1316
The plan language should have a catch_errors functions
Issue Type: New Feature New Feature
Assignee: Unassigned
Created: 2019/05/16 2:22 PM
Priority: Normal Normal
Reporter: Alex Dreyer

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.

$result_or_error = catch_errors([kind1, kind2]) ||{
  run_task(task1)
  run_task(task2)
  run_task(task3)
}

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Alex Dreyer (JIRA)

unread,
May 21, 2019, 12:48:04 PM5/21/19
to puppe...@googlegroups.com
Alex Dreyer updated an issue
Change By: Alex Dreyer
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) || {
  puppetdb_query(....)
}
{noformat}

Alex Dreyer (JIRA)

unread,
May 21, 2019, 12:48:04 PM5/21/19
to puppe...@googlegroups.com
Alex Dreyer updated an issue
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) ||
{

}
{
noformat}

Lucy Wyman (JIRA)

unread,
May 21, 2019, 12:51:03 PM5/21/19
to puppe...@googlegroups.com
Lucy Wyman updated an issue
Change By: Lucy Wyman
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.

{noformat}
$result_or_error = catch_errors([kind1, kind2]) ||{
  run_task(task1)
  run_task(task2)
  run_task(task3)
}

query_result_or_error = catch(errors) || {
  puppetdb_query(....)
}
{noformat}

Lucy Wyman (JIRA)

unread,
May 21, 2019, 12:53:03 PM5/21/19
to puppe...@googlegroups.com
Lucy Wyman updated an issue
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.

{noformat}
$result_or_error = catch_errors([kind1, kind2]) ||{
  run_task(task1)
  run_task(task2)
  run_task(task3)
}

query_result_or_error = catch(errors) || {
  puppetdb_query(....)
}
{noformat}

Lucy Wyman (JIRA)

unread,
May 21, 2019, 12:55:03 PM5/21/19
to puppe...@googlegroups.com
Lucy Wyman updated an issue
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.

{noformat}
$result_or_error = catch_errors([kind1, kind2]) ||{
  run_task(task1)
  run_task(task2)
  run_task(task3)
}

query_result_or_error = catch(errors) || {
  puppetdb_query(....)
}
{noformat}

Lucy Wyman (JIRA)

unread,
May 21, 2019, 12:55:03 PM5/21/19
to puppe...@googlegroups.com
Lucy Wyman updated an issue
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)
}

query_result_or_error = catch(errors) || {
  puppetdb_query(....)
}
{noformat}

Lucy Wyman (JIRA)

unread,
May 21, 2019, 12:56:03 PM5/21/19
to puppe...@googlegroups.com
Lucy Wyman updated an issue
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.

{noformat}
$result_or_error = catch_errors([kind1, kind2]) ||{
  run_task(task1)
  run_task(task2)
  run_task(task3)
}

query_result_or_error = catch(errors) || {
  puppetdb_query(....)
}
{noformat}

Lucy Wyman (JIRA)

unread,
May 21, 2019, 12:56:03 PM5/21/19
to puppe...@googlegroups.com
Lucy Wyman updated an issue
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.

{noformat}
$result_or_error = catch_errors([kind1, kind2]) ||{
  run_task(task1)
  run_task(task2)
  run_task(task3)
}

query_result_or_error = catch(errors) || {
  puppetdb_query(....)
}
{noformat}

Lucy Wyman (JIRA)

unread,
May 21, 2019, 12:57:03 PM5/21/19
to puppe...@googlegroups.com

Lucy Wyman (JIRA)

unread,
May 24, 2019, 12:42:03 PM5/24/19
to puppe...@googlegroups.com

Lucy Wyman (JIRA)

unread,
Jun 11, 2019, 12:57:03 PM6/11/19
to puppe...@googlegroups.com

Lucy Wyman (JIRA)

unread,
Jun 11, 2019, 6:48:03 PM6/11/19
to puppe...@googlegroups.com
Lucy Wyman updated an issue
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.

{noformat}
$result_or_error = catch_errors([kind1, kind2]) ||{
  run_task(task1)
  run_task(task2)
  run_task(task3)
}

query_result_or_error = catch(errors) || {
  puppetdb_query(....)
}
{noformat}

Lucy Wyman (JIRA)

unread,
Jun 12, 2019, 10:19:03 AM6/12/19
to puppe...@googlegroups.com

Tom Beech (JIRA)

unread,
Jun 13, 2019, 7:36:03 PM6/13/19
to puppe...@googlegroups.com
Tom Beech updated an issue
Change By: Tom Beech
Release Notes Summary: 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.
Release Notes: New Feature

Melissa Amos (JIRA)

unread,
Jun 14, 2019, 4:45:04 PM6/14/19
to puppe...@googlegroups.com

Melissa Amos (JIRA)

unread,
Jun 14, 2019, 4:45:04 PM6/14/19
to puppe...@googlegroups.com

Melissa Amos (JIRA)

unread,
Jun 14, 2019, 4:46:03 PM6/14/19
to puppe...@googlegroups.com
Melissa Amos updated an issue
Change By: Melissa Amos
Labels: docs docs_reviewd docs_reviewed
Reply all
Reply to author
Forward
0 new messages