Skip to content

Commit

Permalink
Throw QueryException instead of UnsupportedOperationException for lab…
Browse files Browse the repository at this point in the history
…els() with

aquery.

A runtime exception should really only be used for programming errors. In this
case the code logic is sound, just that the feature isn't supported.

RELNOTES: None
PiperOrigin-RevId: 357664603
  • Loading branch information
joeleba authored and copybara-github committed Feb 16, 2021
1 parent 2576851 commit 4395568
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.devtools.build.lib.query2.engine.QueryException;
import com.google.devtools.build.lib.query2.engine.QueryExpression;
import com.google.devtools.build.lib.query2.engine.QueryVisibility;
import com.google.devtools.build.lib.server.FailureDetails.ActionQuery;
import com.google.devtools.build.lib.server.FailureDetails.ConfigurableQuery;
import com.google.devtools.build.lib.skyframe.AspectValueKey.AspectKey;
import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey;
Expand Down Expand Up @@ -109,7 +110,8 @@ public List<ConfiguredTargetValue> getPrerequisites(
String errorMsgPrefix)
throws QueryException, InterruptedException {
// TODO(bazel-team): implement this if needed.
throw new UnsupportedOperationException();
throw new QueryException(
"labels() is not supported for aquery", ActionQuery.Code.LABELS_FUNCTION_NOT_SUPPORTED);
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/protobuf/failure_details.proto
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ message ActionQuery {
TOP_LEVEL_TARGETS_WITH_SKYFRAME_STATE_NOT_SUPPORTED = 11
[(metadata) = { exit_code: 2 }];
SKYFRAME_STATE_AFTER_EXECUTION = 12 [(metadata) = { exit_code: 1 }];
LABELS_FUNCTION_NOT_SUPPORTED = 13 [(metadata) = { exit_code: 2 }];
}

Code code = 1;
Expand Down

0 comments on commit 4395568

Please sign in to comment.