stevedlawrence commented on code in PR #1058:
URL: https://github.com/apache/daffodil/pull/1058#discussion_r1276193164
##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/DataProcessor.scala:
##########
@@ -340,8 +340,10 @@ class DataProcessor(
* runtime. Instead we deal with success and failure statuses.
*/
def parse(input: InputSourceDataInputStream, output: InfosetOutputter):
DFDL.ParseResult = {
- Assert.usage(!this.isError)
-
+ Assert.argCheck(
+ !this.isError,
+ s"Must check isError before calling DataProcessor parse.
${this.getDiagnostics.mkString}",
Review Comment:
I don't feel strongly about whether we include Diagnostics or not. I'm still
not convinced it makes sense, but if @mbeckerle or others think it's important
then it's fine with me.
But I would suggest that it should be a `cause` to the
`IllegalStateException` and not part of the exception message. The diagnostics
are only a secondary reason for throwing this exception and don't belong in the
message itself.
Maybe the `illegalState` function/macro accepts a third cause parameter, and
it's called something like this:
```scala
Assert.illegalState(isError, "...", diagnostics.find(_.isError).get)
```
The macro would expand to
```scala
if (isError) {
throw new IllegalStateException("...", diagnostics.find(_.isError).get)
}
```
So the message and `diagnostics.find` (or whatever logic is needed) would
only be evaluated if `isError` is true.
--
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]