stevedlawrence commented on a change in pull request #162: Properly handle
malformed binding files
URL: https://github.com/apache/incubator-daffodil/pull/162#discussion_r246367079
##########
File path: daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala
##########
@@ -627,7 +630,22 @@ object Main extends Logging {
val extVarBindingNodeOpt = (configNode \
"externalVariableBindings").headOption
extVarBindingNodeOpt match {
case None => Seq.empty
- case Some(extVarBindingsNode) =>
ExternalVariablesLoader.getVariables(extVarBindingsNode, tunables)
+ case Some(extVarBindingsNode) => {
+ try {
+ ExternalVariablesLoader.getVariables(extVarBindingsNode,
tunables)
+ } catch {
+ case qupe: QNameUndefinedPrefixException => {
+ log(LogLevel.Warning, qupe.getMessage)
+ log(LogLevel.Warning, "Undefined QName prefix in external
variable binding file. Continuing with default values")
+ Seq.empty
+ }
+ case qse: QNameSyntaxException => {
+ log(LogLevel.Warning, qse.getMessage)
+ log(LogLevel.Warning, "QName syntax error in external variable
binding file. Continuing with default values")
+ Seq.empty
+ }
Review comment:
Thoughts on making these fatal errors? If a user provdies a config file with
the intention of changing the behavior of how things will parse and something
is wrong with the file, I'm not sure it makes sense to continue processing. If
making these fatal makes sense, I think you can remove this change and let the
exception bubble up, catch it in ``def main`` with other exceptions, and log an
error.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services