Skip to content

Commit 7b480c9

Browse files
committed
Throw FluxParseException instead of RuntimeException (#421)
1 parent c6d9848 commit 7b480c9

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ tokens {
3333

3434
@header {
3535
package org.metafacture.flux.parser;
36+
37+
import org.metafacture.flux.FluxParseException;
3638
}
3739

3840
@lexer::header {
@@ -48,7 +50,7 @@ catch [RecognitionException re] {
4850
recover(input,re);
4951
retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);
5052
String msg = getErrorMessage(re, this.getTokenNames()) + " in Flux";
51-
throw new RuntimeException(msg, re);
53+
throw new FluxParseException(msg, re);
5254
}
5355

5456
varDef

metafacture-flux/src/test/java/org/metafacture/flux/FluxGrammarTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.junit.Before;
3030
import org.junit.Test;
3131
import org.metafacture.flux.parser.FluxProgramm;
32+
import org.metafacture.framework.MetafactureException;
3233

3334
/**
3435
* Tests for the Flux grammar.
@@ -89,15 +90,15 @@ public void shouldReplaceJavaEscapeSequences()
8990
stdoutBuffer.toString());
9091
}
9192

92-
@Test(expected = RuntimeException.class)
93+
@Test(expected = FluxParseException.class)
9394
public void issue421_shouldThrowRuntimeExceptionWhenSemicolonInFlowIsMissing()
9495
throws RecognitionException, IOException {
9596
final String script = "\"test\"|print";
9697
try {
9798
FluxCompiler.compile(createInputStream(script), emptyMap());
98-
} catch (RuntimeException re) {
99-
assertEquals("mismatched input '<EOF>' expecting ';' in Flux", re.getMessage());
100-
throw re;
99+
} catch (FluxParseException fpe) {
100+
assertEquals("mismatched input '<EOF>' expecting ';' in Flux", fpe.getMessage());
101+
throw fpe;
101102
}
102103
}
103104

0 commit comments

Comments
 (0)