stevedlawrence commented on code in PR #1572:
URL: https://github.com/apache/daffodil/pull/1572#discussion_r2466154176
##########
daffodil-core/src/main/scala/org/apache/daffodil/runtime1/processors/DaffodilUnparseContentHandlerImpl.scala:
##########
@@ -180,9 +180,13 @@ class DaffodilUnparseContentHandlerImpl(dp:
DFDL.DataProcessor, output: DFDL.Out
* coroutine is still unparsing), or if an unexpected exception occurred that
* prevented unparse from completing. Otherwise returns the UnparseResult.
*/
- def getUnparseResult: DFDL.UnparseResult = unparseResult.orNull
+ def getUnparseResult: DFDL.UnparseResult =
+ if (maybeUnparseResultOrException.isDefined)
+ maybeUnparseResultOrException.get.toOption.orNull
+ else
+ null
- private var unparseResult: Maybe[DFDL.UnparseResult] = Nope
+ private var maybeUnparseResultOrException: Maybe[Either[Exception,
DFDL.UnparseResult]] = Nope
Review Comment:
Yep, if the unparse side of the coroutine throws an unexpected exception
(usually indicating bug) we capture that and send it back to the main coroutine
where the main thread can handle it.
Yeah, the `Maybe` is a bit weird, but its needed because the unparse side of
the coroutine could still be processing and just needs more events from the
XMLReader. A value of None indicates that it's not done so we can gather more
events and resume it until it indicates some kind of result (either an
UnparseResult or an exception/bug).
--
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]