[ 
https://issues.apache.org/jira/browse/DAFFODIL-2072?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17168228#comment-17168228
 ] 

Mike Beckerle commented on DAFFODIL-2072:
-----------------------------------------

Need to verify if this is still an issue. Other issues long since resolved have 
reported that we get diagnostics saying that isError was not called, so we may 
be giving the right diagnostics now and this issue may be able to be closed. 

> Poor reporting of schema errors when used as library
> ----------------------------------------------------
>
>                 Key: DAFFODIL-2072
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2072
>             Project: Daffodil
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 2.3.0
>            Reporter: Brandon Sloane
>            Priority: Major
>         Attachments: Main.scala, test.dfdl.xsd
>
>
> When used as a library, Daffodil does not produce a meaningfull error when 
> provided with an invalid schema file.
> Consider the following Scala program (Main.scala):
> {quote}package com.tresys.test
> import org.apache.daffodil.sapi.Daffodil
> import org.apache.daffodil.sapi.Compiler
> import org.apache.daffodil.util.Misc
> import org.apache.daffodil.sapi.ProcessorFactory
> import org.apache.daffodil.sapi.DataProcessor
> import org.apache.daffodil.api.URISchemaSource
> object Main extends App {
>  override def main(args: Array[String]): Unit = {
>  val dfdlCompiler: Compiler = Daffodil.compiler()
>  val model = Misc.getRequiredResource("test.dfdl.xsd")
>  val pf: ProcessorFactory = 
> dfdlCompiler.compileSource(URISchemaSource(model).uriForLoading)
>  val df: DataProcessor = pf.onPath("/")
>  }
> }
> {quote}
> The relevent portion of test.dfdl.xsd is:
> {quote}<xs:element name="top" type="tns:nonexistant" />
> {quote}
> where tns:nonexistant is never defined.
> {quote}Executing Main.scala produces the following error:
> Exception in thread "main" org.apache.daffodil.exceptions.Abort: Usage error: 
> ProcessorFactory.this.isError.unary_!
> org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
> org.apache.daffodil.compiler.ProcessorFactory.$anonfun$onPath$1(Compiler.scala:131)
> scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
> org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
>  at org.apache.daffodil.exceptions.Assert$.abort(Assert.scala:129)
>  at 
> org.apache.daffodil.compiler.ProcessorFactory.$anonfun$onPath$1(Compiler.scala:131)
>  at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
>  at 
> org.apache.daffodil.ExecutionMode$.$anonfun$usingCompilerMode$1(ExecutionMode.scala:64)
>  at org.apache.daffodil.compiler.ProcessorFactory.onPath(Compiler.scala:130)
>  at org.apache.daffodil.sapi.ProcessorFactory.onPath(Daffodil.scala:273)
>  at com.tresys.test.Main$.main(Main.scala:16)
>  at com.tresys.test.Main.main(Main.scala)
> {quote}
> For reference, using the CLI produces the following (good) error:
> {quote}[error] Schema Definition Error: Error loading schema due to 
> org.xml.sax.SAXParseException; systemId: 
> file:/home/bsloane/workspace/Test/src/test.dfdl.xsd; lineNumber: 35; 
> columnNumber: 51; src-resolve: Cannot resolve the name 'tns:nonexistant' to 
> a(n) 'type definition' component.
> Schema context: file:/home/bsloane/workspace/Test/src/test.dfdl.xsd Location 
> in file:??
> {quote}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to