Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split CelEvaluationException from runtime build target #555

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion runtime/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ package(

java_library(
name = "runtime",
exports = ["//runtime/src/main/java/dev/cel/runtime"],
exports = [
"//runtime/src/main/java/dev/cel/runtime",
"//runtime/src/main/java/dev/cel/runtime:evaluation_exception",
],
)

java_library(
Expand Down
14 changes: 12 additions & 2 deletions runtime/src/main/java/dev/cel/runtime/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ java_library(

# keep sorted
RUNTIME_SOURCES = [
"CelEvaluationException.java",
"CelFunctionOverload.java",
"CelFunctionResolver.java",
"CelLateFunctionBindings.java",
Expand All @@ -157,12 +156,24 @@ RUNTIME_SOURCES = [
"UnknownContext.java",
]

java_library(
name = "evaluation_exception",
srcs = ["CelEvaluationException.java"],
tags = [
],
deps = [
"//common",
"//common:error_codes",
],
)

java_library(
name = "runtime",
srcs = RUNTIME_SOURCES,
tags = [
],
deps = [
":evaluation_exception",
":evaluation_listener",
":runtime_helper",
":runtime_type_provider_legacy",
Expand All @@ -186,7 +197,6 @@ java_library(
"@maven//:com_google_guava_guava",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_google_protobuf_protobuf_java_util",
"@maven//:com_google_re2j_re2j",
"@maven//:org_jspecify_jspecify",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ public CelEvaluationException(String message, Throwable cause) {
super(formatErrorMessage(message), cause);
}

public CelEvaluationException(String message, Throwable cause, CelErrorCode errorCode) {
super(formatErrorMessage(message), cause, errorCode);
}

public CelEvaluationException(String message, CelErrorCode errorCode) {
super(formatErrorMessage(message), errorCode);
}

CelEvaluationException(InterpreterException cause, CelErrorCode errorCode) {
super(cause.getMessage(), cause.getCause(), errorCode);
public CelEvaluationException(String message, Throwable cause, CelErrorCode errorCode) {
this(message, cause, errorCode, true);
}

CelEvaluationException(
String message, Throwable cause, CelErrorCode errorCode, boolean formatErrorMessage) {
super(formatErrorMessage ? formatErrorMessage(message) : message, cause, errorCode);
}

private static String formatErrorMessage(String message) {
Expand Down
3 changes: 2 additions & 1 deletion runtime/src/main/java/dev/cel/runtime/CelRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ private static CelEvaluationException unwrapOrCreateEvaluationException(
if (e.getCause() instanceof CelEvaluationException) {
return (CelEvaluationException) e.getCause();
}
return new CelEvaluationException(e, e.getErrorCode());

return new CelEvaluationException(e.getMessage(), e.getCause(), e.getErrorCode(), false);
}
}

Expand Down
Loading