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

Mike Beckerle commented on DAFFODIL-2843:
-----------------------------------------

I took a look at the code. 

LayerException is never caught, but the the only usage is for 
LayerNotEnoughDataException which is caught and converted to a PE when parsing. 
LayerException are ThinDiagnostics so don't carry a stack trace. They are 
intended for use in processing errors that might be frequent on account of 
backtracking/speculative parsing. 

So one flaw is that we're only catching LayerNotEnoughDataException when we 
should be catching LayerException.

I believe LayerException should be renamed to LayerProcessingException, where 
the "ProcessingException" suffix is intended to mean the DFDL interpretation of 
that term, which is a parse or unparse error. 

LayerExecutionException is just a RuntimeException, which is just the usual 
re-encapsulation of whatever the real exception is as the cause of the 
LayerExecutionException. 

Probably should be renamed to LayerFatalException as this is always a bug 
indication. 

I think the approach is this: the layer transformer code itself should be 
responsible for converting any exception into some kind of 
LayerProcessingException which is caught and becomes a parse error when 
parsing, unparse error when unparsing. 

For example, suppose the gzip layer code throws a a null pointer exception on 
certain bad data cases. Then the gzip layer transformer should catch NPE and 
convert to a LayerProcessingException and throw that. 

Any other exception thrown from a layer transformer is either unavoidable (Like 
a Java JVM out-of-memory exception), or is a bug in the layer that it wasn't 
anticipated and caught. These are what turn into a LayerExecutionException 
which is essentially a bug indication. 

 

> Unclear how to create Parse/UnparseError from ParseOrUnparseState
> -----------------------------------------------------------------
>
>                 Key: DAFFODIL-2843
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2843
>             Project: Daffodil
>          Issue Type: Bug
>          Components: Back End
>    Affects Versions: 3.5.0
>            Reporter: Olabusayo Kilo
>            Priority: Major
>
> It is unclear how to create a parse/unparse error using ParseOrUnparseState 
> while creating a layer transform. Currently we can create a SDE using 
> ParseOrUnparseState, but there are situations where the issue is with the 
> data, not the schema. 
> A possible workaround is to manually recreate what PE and UE do as in:
> {code:scala}
> parserOrUnparseState match {
>   case pstate: PState => // do what PE(...) does
>   case ustate: UState => // do what UE(...) does
> }
> {code}
> Related to DAFFODIL-2841



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to