Uploaded image for project: 'Puppet Task Runner'
  1. Puppet Task Runner
  2. BOLT-1316

The plan language should have a catch_errors functions

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: BOLT 1.23.0
    • Component/s: None
    • Template:
    • Sprint:
      Bolt Kanban
    • Release Notes:
      New Feature
    • 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.
    • QA Risk Assessment:
      Needs Assessment

      Description

      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 behave 'normally' - 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.

      $result_or_error = catch_errors([kind1, kind2]) ||{
        run_task(task1)
        run_task(task2)
        run_task(task3)
      }
       
      query_result_or_error = catch(errors) || {
        puppetdb_query(....)
      }
      

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                lucy Lucy Wyman
                Reporter:
                alex Alex Dreyer
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: