You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by "Renaud Richardet (JIRA)" <de...@uima.apache.org> on 2015/07/20 10:04:04 UTC

[jira] [Comment Edited] (UIMA-4517) fixing ArrayOutOfBounds exception when parsing invalid Ruta script

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

Renaud Richardet edited comment on UIMA-4517 at 7/20/15 8:03 AM:
-----------------------------------------------------------------

Notes:

- The reason to throw a RuntimeException is that the RutaParser's base class does not throws checked Exceptions for emitErrorMessage() methods.
- some of the code from RutaParser.g, public void emitErrorMessage(RecognitionException e), could be moved to RutaParseRuntimeException


was (Author: renaudrichardet):
Notes:

- The reason to throw a RuntimeException is that the RutaParser's base class does not throws Exceptions for emitErrorMessage() methods.
- some of the code from RutaParser.g, public void emitErrorMessage(RecognitionException e), could be moved to RutaParseRuntimeException

> fixing ArrayOutOfBounds exception when parsing invalid Ruta script
> ------------------------------------------------------------------
>
>                 Key: UIMA-4517
>                 URL: https://issues.apache.org/jira/browse/UIMA-4517
>             Project: UIMA
>          Issue Type: Bug
>          Components: ruta
>    Affects Versions: 2.3.1ruta
>            Reporter: Renaud Richardet
>            Assignee: Peter Klügl
>            Priority: Minor
>             Fix For: 2.3.1ruta
>
>         Attachments: RutaParseRuntimeException.java, RutaParser.diff, RutaParser2.diff
>
>
> looking for more informative exception messages when parsing invalid Ruta script
> When using Ruta in a non-Workbench setup (in my case, Maven), I don't manage to catch Ruta script errors in a meaningful way. Here is an example:
> "aaa\." -> MyAnnotation; // fails because of escaped dot
> The thrown error is quite uninformative:
> java.lang.ArrayIndexOutOfBoundsException: -1
> 	at org.apache.uima.ruta.parser.RutaParser.emitErrorMessage(RutaParser.java:365)
> 	at org.apache.uima.ruta.parser.RutaParser.reportError(RutaParser.java:386)
> 	at org.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(BaseRecognizer.java:603)
> 	at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:115)
> 	at org.apache.uima.ruta.parser.RutaParser.file_input(RutaParser.java:680)
> 	at org.apache.uima.ruta.engine.RutaEngine.loadScript(RutaEngine.java:1058)
> 	at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:743)
> 	...
> Here is the code to reproduce: https://github.com/renaud/annotate_ruta_example/tree/ruta_error_message
> However, if I paste that script line in the Ruta Workbench, it nicely underlines it in red at the exact location, and even says "Mismatched input". How do I achieve the same programatically (from Java)?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)