stevedlawrence commented on code in PR #1515:
URL: https://github.com/apache/daffodil/pull/1515#discussion_r2243382454


##########
daffodil-cli/src/main/scala/org/apache/daffodil/cli/Main.scala:
##########
@@ -184,21 +180,21 @@ class CLIConf(arguments: Array[String], stdout: 
PrintStream, stderr: PrintStream
 
       s match {
         case DefaultArgPattern(name, arg) if Validators.isRegistered(name) =>
-          if (doesNotSupportReloadableParsers(name)) {
-            null
+          if (Seq(".conf", ".properties").exists(arg.endsWith)) {
+            val is = new FileInputStream(arg)
+            props.load(is)
           } else {
-            if (Seq(".conf", ".properties").exists(arg.endsWith)) {
-              val is = new FileInputStream(arg)
-              props.load(is)
-            } else {
-              val uss = fileResourceToURI(arg)
-              props.setProperty(name, uss.uri.toString)
-            }
-            Validators.get(name).make(props)
+            val uss = fileResourceToURI(arg)
+            props.setProperty(name, uss.uri.toString)
           }
+          Validators.get(name).make(props)
         case NoArgsPattern(name) if Validators.isRegistered(name) =>
-          if (doesNotSupportReloadableParsers(name)) {
-            null
+          val missingRequiredSchema =
+            parser.isDefined && !Seq("limited", "off").exists(_.contains(name))
+          if (missingRequiredSchema) {
+            throw new Exception(
+              "To use full validation with a saved parser, the validating 
schema must be provided ex: xerces=/path/to/schema.xsd"

Review Comment:
   I don't think we need a specific exception message here at all. We can just 
try to to create the Validator where ever that happens, and if that fails (e.g. 
because no rootSchema is defined) then it should throw an exception which can 
be caught and displayed by the CLI as an error. I think it's fine if the 
message doesn't include limited/off, since the users didn't want to use limited 
or off in the first place.
   
   So for example, if they try to do something like
   
   ```
   daffodil parse -P foo.bin -V xerces ...
   ```
   
   Then the xerces validator would throw an exception like "Schema required to 
create Xerces validator". That will get caught by the CLI and displayed as an 
error. It's maybe not as obvious what the fix is do to `--validate 
xerces=path/to/schema.xsd`, but maybe we can add a blurb in the --validate help 
that if to -P is used then some validators might require a config file 
specified.



-- 
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]

Reply via email to