Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-7368

Add ability to declare function argument mismatch handlers

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.10.0
    • Component/s: Docs
    • Labels:
      None
    • Template:
    • Epic Link:
    • Sub-team:
    • Team:
      Agent
    • Story Points:
      2
    • Sprint:
      PDE 2017-03-22, PDE 2017-04-05
    • Release Notes:
      New Feature
    • Release Notes Summary:
      The modern (4.x) Function API for Ruby has been extended to accept the definition of {{argument_mismatch}} dispatchers. These can now be used to provide better custom error messages when a type mismatch occurs in a function call.
    • QA Risk Assessment:
      No Action
    • QA Risk Assessment Reason:
      covered by unit tests

      Description

      An alternative function dispatch is needed that can produce error messages for the arguments that it matches. It can be named argument_mismatch. The matching algorithm should be exactly the same as as for a normal dispatch but the function that gets called must produce a String describing that the matched arguments are in fact in error. An ArgumentError with this message should then be raised when the function returns.

      Dispatchers of type `argument_mismatch` will be excluded when the default argument mismatch handler describes viable options. It is also excluded from the list of dispatchers returned from the Dispatcher.

      A function may have zero to many argument_mismatch declarations and when none of them matches, the default mismatch describer still kicks in.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              thomas.hallgren Thomas Hallgren
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support