From 335f2c1d70fe922c1bedfcb2d7d7751d5adb723c Mon Sep 17 00:00:00 2001 From: Clint Valentine Date: Tue, 23 Apr 2019 11:33:03 -0700 Subject: [PATCH] Improve exception message for unset VCF output type (#1357) * Improve exception message for unset VCF output type * Add valid VCF extensions and attempted outPath to exception message * outPath can be null for streams * Better formatting on message --- .../writer/VariantContextWriterBuilder.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/htsjdk/variant/variantcontext/writer/VariantContextWriterBuilder.java b/src/main/java/htsjdk/variant/variantcontext/writer/VariantContextWriterBuilder.java index d809d3aff0..83161734ee 100644 --- a/src/main/java/htsjdk/variant/variantcontext/writer/VariantContextWriterBuilder.java +++ b/src/main/java/htsjdk/variant/variantcontext/writer/VariantContextWriterBuilder.java @@ -44,6 +44,8 @@ import java.nio.file.Path; import java.util.EnumSet; +import static htsjdk.samtools.util.IOUtil.VCF_EXTENSIONS_LIST; + /* * Created with IntelliJ IDEA. * User: thibault @@ -453,7 +455,12 @@ else if (STREAM_TYPES.contains(this.outType)) switch (typeToBuild) { case UNSPECIFIED: - throw new IllegalArgumentException("Must specify file or stream output type."); + throw new IllegalArgumentException( + "Output format type is not set, or could not be inferred from the output path. " + + "If a path was used, does it have a valid VCF extension (" + + String.join(", ", VCF_EXTENSIONS_LIST) + + ")?" + ); case VCF: if ((refDict == null) && (options.contains(Options.INDEX_ON_THE_FLY))) throw new IllegalArgumentException("A reference dictionary is required for creating Tribble indices on the fly");