Skip to content

Commit 01fb98a

Browse files
committed
Throw RuntimeException in FluxParser (#421)
If a `RecognitionException` occurs in `FluxParser` it was catched. So callers had no chance to be aware of the Exception. As it's not possible to create a new `RecognitionException` with a customized error message (and throw this new `RecognitionException`) and also to be backwards compatibel (`RuntimeExceptions` are referred to as unchecked exceptions and the code would compile just as before) no checked Exception is thrown but a `RuntimeException` with the customized error message.
1 parent 66a1826 commit 01fb98a

File tree

1 file changed

+13
-0
lines changed
  • metafacture-flux/src/main/antlr/org/metafacture/flux/parser

1 file changed

+13
-0
lines changed

metafacture-flux/src/main/antlr/org/metafacture/flux/parser/Flux.g

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ flux
4343
:
4444
varDef* flow*
4545
;
46+
catch [RecognitionException re] {
47+
reportError(re);
48+
recover(input,re);
49+
retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);
50+
String msg = getErrorMessage(re, this.getTokenNames()) + " in Flux";
51+
throw new RuntimeException(msg, re);
52+
}
4653

4754
varDef
4855
:
@@ -63,6 +70,12 @@ flow
6370
)
6471
'|'! flowtail ('|'! Wormhole)? ';'!
6572
;
73+
catch [RecognitionException re] {
74+
reportError(re);
75+
recover(input,re);
76+
retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);
77+
throw re;
78+
}
6679

6780
tee
6881
:

0 commit comments

Comments
 (0)