Skip to content

Commit 0f4093e

Browse files
authored
Include AST issues display string in compilation error (#14)
Including the errors from the compiler makes it easier to find and fix errors. For example this signed-versus-unsigned type error: ``` build.buf.protovalidate.exceptions.CompilationException: Failed to compile expression id.non_zero: ERROR: <input>:1:28: found no matching overload for '_!=_' applied to '(uint, int)' | this.most_significant_bits != 0 || this.least_significant_bits != 0u | ...........................^ ```
1 parent 9d1946d commit 0f4093e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/build/buf/protovalidate/internal/expression/AstExpression.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public static AstExpression newAstExpression(Env env, Expression expr)
4545
throws CompilationException {
4646
Env.AstIssuesTuple astIssuesTuple = env.compile(expr.expression);
4747
if (astIssuesTuple.hasIssues()) {
48-
throw new CompilationException("Failed to compile expression " + expr.id);
48+
throw new CompilationException(
49+
"Failed to compile expression " + expr.id + ":\n" + astIssuesTuple.getIssues());
4950
}
5051
Ast ast = astIssuesTuple.getAst();
5152
Type outType = ast.getResultType();

0 commit comments

Comments
 (0)