This is an automated email from the ASF dual-hosted git repository.

olabusayo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git


The following commit(s) were added to refs/heads/main by this push:
     new 4ef4a5c98 Fix handling of exceptions in DPath evaluation
4ef4a5c98 is described below

commit 4ef4a5c987295dc74b1db4ceb66e430643008449
Author: olabusayoT <[email protected]>
AuthorDate: Mon Aug 25 15:03:18 2025 -0400

    Fix handling of exceptions in DPath evaluation
    
    - Properly wrap non-Daffodil exceptions in `ExpressionEvaluationException`.
    - Avoid redundant wrapping for `ProcessingError` and `Diagnostic` 
exceptions.
    
    DAFFODIL-3001
---
 .../scala/org/apache/daffodil/runtime1/dpath/DPath.scala  | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/dpath/DPath.scala 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/dpath/DPath.scala
index b35db0c09..54a163bb6 100644
--- 
a/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/dpath/DPath.scala
+++ 
b/daffodil-core/src/main/scala/org/apache/daffodil/runtime1/dpath/DPath.scala
@@ -114,15 +114,20 @@ final class RuntimeExpressionDPath[T <: AnyRef](
       case null => Assert.usageError("state cannot be null")
       case ustate: UState => UE(e, One(ustate.currentLocation))
       case pstate: PState => {
-        val pe =
-          new ExpressionEvaluationException(
-            e,
-            state
-          ) // One(ci.schemaFileLocation), One(pstate.currentLocation), msg)
+        val pe = e match {
+          // if this is a non-daffodil exception, it needs to be wrapped in a
+          // Daffodil Exception like ExpressionEvaluationException. If it's 
not (i.e Processing Error),
+          // we don't need to wrap it in anything.
+          case _pe: ProcessingError => _pe
+          case _ => new ExpressionEvaluationException(e, state)
+        }
         pstate.setFailed(pe.toParseError)
       }
       case compState: CompileState => {
         val d = e match {
+          // if this is a non-daffodil exception, it needs to be wrapped in a
+          // Daffodil Exception like ExpressionEvaluationException. If it's 
not (i.e Diagnostic),
+          // we don't need to wrap it in anything.
           case d: Diagnostic => d
           case _ =>
             new ExpressionEvaluationException(e, state)

Reply via email to