-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add exception factory for cesql exceptions - extend EvaluationResult to be usable internally - expressions use results instead of a thrower interface - functions use results instead of a thrower interface - parser handles not equals correctly, does not eagerly evaluate when there may be an error - parser handles integer literals properly - updated test files to test v1 spec Signed-off-by: Calum Murray <[email protected]> Co-authored-by: Pierangelo Di Pilato <[email protected]>
- Loading branch information
Showing
80 changed files
with
839 additions
and
702 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
sql/src/main/java/io/cloudevents/sql/ExceptionFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.cloudevents.sql; | ||
|
||
import org.antlr.v4.runtime.RecognitionException; | ||
import org.antlr.v4.runtime.misc.Interval; | ||
import org.antlr.v4.runtime.tree.ParseTree; | ||
|
||
public interface ExceptionFactory { | ||
EvaluationException.EvaluationExceptionFactory invalidCastTarget(Class<?> from, Class<?> to); | ||
|
||
EvaluationException.EvaluationExceptionFactory castError(Class<?> from, Class<?> to, Throwable cause); | ||
|
||
EvaluationException missingAttribute(Interval interval, String expression, String key); | ||
|
||
EvaluationException cannotDispatchFunction(Interval interval, String expression, String functionName, Throwable cause); | ||
|
||
EvaluationException.EvaluationExceptionFactory functionExecutionError(String functionName, Throwable cause); | ||
|
||
EvaluationException divisionByZero(Interval interval, String expression, Integer dividend); | ||
|
||
EvaluationException mathError(Interval interval, String expression, String errorMessage); | ||
|
||
static ParseException cannotParseValue(ParseTree node, Type target, Throwable cause) { | ||
return new ParseException( | ||
ParseException.ErrorKind.PARSE_VALUE, | ||
node.getSourceInterval(), | ||
node.getText(), | ||
"Cannot parse to " + target.name() + ": " + cause.getMessage(), | ||
cause | ||
); | ||
} | ||
|
||
static ParseException recognitionError(RecognitionException e, String msg) { | ||
return new ParseException( | ||
ParseException.ErrorKind.RECOGNITION, | ||
new Interval(e.getOffendingToken().getStartIndex(), e.getOffendingToken().getStopIndex()), | ||
e.getOffendingToken().getText(), | ||
"Cannot parse: " + msg, | ||
e | ||
); | ||
} | ||
|
||
static ParseException cannotEvaluateConstantExpression(EvaluationException exception) { | ||
return new ParseException( | ||
ParseException.ErrorKind.CONSTANT_EXPRESSION_EVALUATION, | ||
exception.getExpressionInterval(), | ||
exception.getExpressionText(), | ||
"Cannot evaluate the constant expression: " + exception.getExpressionText(), | ||
exception | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 0 additions & 107 deletions
107
sql/src/main/java/io/cloudevents/sql/impl/ExceptionFactory.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.