aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/genquery
diff options
context:
space:
mode:
authorGravatar juliexxia <juliexxia@google.com>2018-05-09 08:01:05 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-09 08:02:12 -0700
commitc1085c6d8244fb32f29c355f12ce3c27ba9f2776 (patch)
tree70d823f2976d0412c2ab32946edcc2524c914150 /src/main/java/com/google/devtools/build/lib/rules/genquery
parent0c94ec371dcf68e7e7b89fecc2561d16622fe112 (diff)
Add graceful failure for unsupported formatters in genquery
PiperOrigin-RevId: 195971237
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/genquery')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/genquery/GenQuery.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/genquery/GenQuery.java b/src/main/java/com/google/devtools/build/lib/rules/genquery/GenQuery.java
index 95c45dea83..71eafc303b 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/genquery/GenQuery.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/genquery/GenQuery.java
@@ -311,6 +311,13 @@ public class GenQuery implements RuleConfiguredTargetFactory {
formatter =
OutputFormatter.getFormatter(
OutputFormatter.getDefaultFormatters(), queryOptions.outputFormat);
+ if (formatter == null) {
+ ruleContext.ruleError(String.format(
+ "Invalid output format '%s'. Valid values are: %s",
+ queryOptions.outputFormat,
+ OutputFormatter.formatterNames(OutputFormatter.getDefaultFormatters())));
+ return null;
+ }
// All the packages are already loaded at this point, so there is no need
// to start up many threads. 4 are started up to make good use of multiple
// cores.