You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "mbeckerle (via GitHub)" <gi...@apache.org> on 2023/08/01 20:04:50 UTC
[GitHub] [daffodil] mbeckerle commented on a diff in pull request #1058: Better Error Reporting for Library API
mbeckerle commented on code in PR #1058:
URL: https://github.com/apache/daffodil/pull/1058#discussion_r1281100710
##########
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:
We can pass the constructor of IllegalStateException both a message string AND a cause.
Then the string can explain that you must call 'isError' to ensure there are not errors, but the error creating that situation is still featured also.
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org