tuxji commented on code in PR #1196:
URL: https://github.com/apache/daffodil/pull/1196#discussion_r1542156669


##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/api/DFDLParserUnparser.scala:
##########
@@ -236,8 +236,12 @@ object DFDL {
    * Thrown by the DaffodilUnparseConentHandler when an unexpected error
    * occurs, this usually represents a bug in Daffodil
    */
-  class DaffodilUnhandledSAXException(description: String, cause: Exception)
-    extends SAXException(description, cause)
+  class DaffodilUnhandledSAXException(description: String, cause: Throwable)
+    extends SAXException(description, new Exception(cause)) {

Review Comment:
   Correct, SAXException accepts only an Exception as its cause argument.  
Agreed, DaffodilUnhandledSAXException should accept only Exception and refrain 
from wrapping the cause twice.



##########
daffodil-core/src/test/scala/org/apache/daffodil/core/processor/TestSAXUnparseAPI.scala:
##########
@@ -200,4 +202,34 @@ class TestSAXUnparseAPI {
     assertTrue(m.contains("prior to end"))
     assertTrue(m.contains("{http://example.com}list";))
   }
+
+  @Test def testDaffodilUnhandledSAXException_creation_bothMessageAndCause(): 
Unit = {
+    val message = "Error Message"
+    val thr = new IllegalArgumentException("Illegal Argument Message")
+    val e = new DaffodilUnhandledSAXException(message, thr)
+    assertEquals(message, e.getMessage)
+    // we call getCause twice here, because the cause is wrapped in an 
Exception before
+    // being returned
+    assertEquals(thr, e.getCause.getCause)

Review Comment:
   All these tests will need to be changed to call getCause only once.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to