You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2020/05/06 14:08:06 UTC

[GitHub] [incubator-daffodil] mbeckerle commented on a change in pull request #378: Added try/catch for potential unparse exceptions

mbeckerle commented on a change in pull request #378:
URL: https://github.com/apache/incubator-daffodil/pull/378#discussion_r420817939



##########
File path: daffodil-runtime1/src/main/scala/org/apache/daffodil/infoset/InfosetInputter.scala
##########
@@ -420,7 +420,14 @@ abstract class InfosetInputter
         }
       } else if (erd.outputValueCalcExpr.isEmpty) {
         val primType = elem.erd.optPrimType.get
-        val obj = primType.fromXMLString(txt)
+        val obj = try {
+          primType.fromXMLString(txt)

Review comment:
       Yeah, we should make fromXMLString a tighter API which throws a specific exception when unable to convert. This is a case where Scala not enforcing handling of exceptions is not doing us a favor however. 
   
   A perhaps more Scala-ish way of doing this is to make it return a Try[String] object instead of throwing, though we tend to avoid objects like Try, Option/Some, or little crud tuples, etc. in the runtime. Unfortunately we don't have our own non-allocating version of Try[T] as yet.

##########
File path: daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/SimpleTypes.tdml
##########
@@ -3981,7 +3982,27 @@
       </tdml:dfdlInfoset>
     </tdml:infoset>
   </tdml:parserTestCase>
+
+   <!--
+    Test name: binaryInt_unparseError
+    Schema: SimpleTypes-binary
+    Purpose: Unparse a binary int with a value that is too large to be an xs:int
+  -->
   
+  <tdml:unparserTestCase name="binaryInt_unparseError" root="int02" roundTrip="false"
+      model="SimpleTypes-binary" description="Section 5 Schema types - int - DFDL-5-013R">
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <ex:int02>7089904312036126320</ex:int02>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+    <tdml:document>7089904312036126320</tdml:document>

Review comment:
       This is a TDML runner bug. It's not checking for this. The XML schema for TDML could be tightened up to enforce this I think. There's already a JIRA ticket about this. 




----------------------------------------------------------------
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:
users@infra.apache.org