Skip to content

Commit

Permalink
Include AST issues display string in compilation error (#14)
Browse files Browse the repository at this point in the history
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
 | ...........................^
```
  • Loading branch information
plobsing authored Sep 11, 2023
1 parent 9d1946d commit 0f4093e
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public static AstExpression newAstExpression(Env env, Expression expr)
throws CompilationException {
Env.AstIssuesTuple astIssuesTuple = env.compile(expr.expression);
if (astIssuesTuple.hasIssues()) {
throw new CompilationException("Failed to compile expression " + expr.id);
throw new CompilationException(
"Failed to compile expression " + expr.id + ":\n" + astIssuesTuple.getIssues());
}
Ast ast = astIssuesTuple.getAst();
Type outType = ast.getResultType();
Expand Down

0 comments on commit 0f4093e

Please sign in to comment.