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

Improve how type mismatches are asserted and reported

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.4.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Story Points:
      2
    • Sprint:
      Language 2016-02-24, Language 2016-03-09, Language 2016-03-23
    • Release Notes:
      New Feature
    • Release Notes Summary:
      The error message generated from the function asssert_type is now of the same high quality as the message produced for automatically type checked parameters.

      Description

      Type assertion and reporting could be greatly improved and also made consistent by fixing three minor things.

      1. The TypeAsserter methods takes a subject parameter that explains in what context the assertion takes place. It is often desirable to create this subject string from things in that context (i.e. format a string). Formatting strings that may or may not be used is however not a good practice since the formatting itself is resource consuming. Deferred formatting can be enabled by a) allowing an Array argument where the first element is a format string and the remaining elements are parameters to that format string, and b) allowing a block to be passed in the calls to the TypeAsserter. The block is called with the subject parameter as it's argument and returns a new subject.
      2. The TypeAsserter currently creates it's own "type mismatch" based on the subject and the compared types. It should instead utilize the TypeMismatchDescriber
      3. The Puppet function assert_type has it's own logic for asserting and printing errors. It should use the TypeAsserter.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support