stevedlawrence commented on code in PR #1058:
URL: https://github.com/apache/daffodil/pull/1058#discussion_r1281812601
##########
daffodil-lib/src/main/scala/org/apache/daffodil/lib/api/Diagnostic.scala:
##########
@@ -308,4 +308,12 @@ trait WithDiagnostics {
* then one can proceed to run the compiled entity.
*/
def isError: Boolean
+
+ /**
+ * Helper method to check that isError is false, if not it throws
+ * a usage error caused by illegal state caused by a compilation error
+ */
+ def checkNotError(): Unit = {
+ Assert.usage(!isError, new
IllegalStateException(getDiagnostics.find(_.isError).get))
Review Comment:
Seems reasonable to me.
I forget why we added `IllegalStateException`, but maybe we don't even need
it anymore? Now that `UsageException` accepts a cause maybe this is just:
```
def checkNotError(): Unit = {
Assert.usage(!isError,
"Must call isError() to ensure there are no errors",
getDiagnostics.find(_.isError).get,
)
}
```
I don't feel strongly about it. Either works for me if having
`IllegalStateException` provides extra useful information.
--
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]