stevedlawrence commented on a change in pull request #204: Provide more detail
for failed assertions
URL: https://github.com/apache/incubator-daffodil/pull/204#discussion_r278089339
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/AssertPatternParsers.scala
##########
@@ -75,7 +77,16 @@ class AssertPatternParser(
val isMatch = dis.lookingAt(m, start)
if (!isMatch) {
val message = getAssertFailureMessage(start)
- val diag = new AssertionFailed(context.schemaFileLocation, start,
message)
+
+ Assert.invariant(start.currentNode.isDefined)
+ val currentElem = start.currentNode.get
+ val details = if (currentElem.isSimple) {
+ "\nParsed value was: " + currentElem.toString
+ } else {
+ "<" + currentElem.name + ">...</" + currentElem.name + ">"
+ }
+
+ val diag = new AssertionFailed(context.schemaFileLocation, start,
message, Maybe.One(details))
Review comment:
Yeah, I think that's how I'm leaning.
I think the default message has improved alot since this bug was originally
created. And we also fixed the issue that prevented the ``message`` attribute
from being an expression. So if someone really wants extra information they can
create a custom message expression to get exactly what information is relevant.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services