diff --git a/common/src/main/java/dev/cel/common/CelAbstractSyntaxTree.java b/common/src/main/java/dev/cel/common/CelAbstractSyntaxTree.java index 6b3b6a74f..b79c67e79 100644 --- a/common/src/main/java/dev/cel/common/CelAbstractSyntaxTree.java +++ b/common/src/main/java/dev/cel/common/CelAbstractSyntaxTree.java @@ -103,6 +103,11 @@ public Optional getType(long exprId) { return Optional.ofNullable(types().get(exprId)); } + public CelType getTypeOrThrow(long exprId) { + return getType(exprId) + .orElseThrow(() -> new NoSuchElementException("Type not found for expr id: " + exprId)); + } + public ImmutableMap getTypeMap() { return types(); }