Uploaded image for project: 'Daffodil'
  1. Daffodil
  2. DFDL-752

Assertion failure message should show value that led to failure.

XMLWordPrintableJSON

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • s11-M1, s11
    • s10
    • Back End
    • None

      We need to show the infoset element as part of the assertion failure message, specifically for an assertion on an element of simple type.

      (For an assert on a complex type element, or a sequence or choice, it's trickier. There I think we could show the infoset object, but as in many places where we need to show this, we need to be able to elide unnecessary substructure or parent structure. Otherwise these will get big and unweildy. - separate JIRA issue should we decide to go there.)

      -------------------------------------
      From: Garriss Jr., James P. [jgarriss@mitre.org]
      Sent: Friday, June 07, 2013 10:23 AM
      To: Mike Beckerle; Stephen Lawrence
      Subject: [daffodil 0.10] Error message improvement suggestion

      I have this simple input:

      MIME-Version: dog

      Obviously invalid. I’m describing it with this schema:

      <xsd:element name="MimeVersion" dfdl:initiator="MIME-Version:%SP;" dfdl:terminator="%NL;" dfdl:length="3" dfdl:lengthKind="explicit">
      <xsd:annotation>
      <xsd:appinfo source="http://www.ogf.org/dfdl/dfdl-1.0/">
      <dfdl:assert test="

      { dfdl:checkConstraints(.) }

      " message="MIME-Version must have a value of '1.0'."/>
      </xsd:appinfo>
      </xsd:annotation>
      <xsd:simpleType>
      <xsd:restriction base="xsd:string">
      <xsd:enumeration value="1.0"/>
      </xsd:restriction>
      </xsd:simpleType>
      </xsd:element>

      The error message I get is:

      [error] Parse Error: Assertion failed. MIME-Version must have a value of '1.0'.

      Schema context: element.MimeVersion Location line 13 column 135 in file:/C:/…/MimeVersion.xsd

      Data location was preceding byte 19

      UTF-8 text starting at byte 16 is: (g

      )

      Data (hex) starting at byte 16 is: (0x670D0A)

      Getting my assertion message back is helpful, as it tells me what the right value should be. But I think this error could be improved by also telling me what value was found. Perhaps the message could look at bit more like this:

      [parsing error] While processing the MimeVersion element, the value “dog” was found.

      This fails the assertion: MIME-Version must have a value of '1.0'.

      Schema: Location line 13 column 135 in file:/C:/…/MimeVersion.xsd

              efinnegan Elizabeth Finnegan
              mbeckerle.dfdl Mike Beckerle
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 20 minutes
                  20m