From b01bc7faff5d9c034160fd41c507642c36b82b97 Mon Sep 17 00:00:00 2001 From: TrickyPi <33021497+TrickyPi@users.noreply.github.com> Date: Sat, 19 Mar 2022 07:18:50 +0800 Subject: fix(cli): improve `deno compile` error messages (#13944) Co-authored-by: David Sherret --- cli/tools/standalone.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'cli/tools') diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs index 8d574aec7..dc9ca4508 100644 --- a/cli/tools/standalone.rs +++ b/cli/tools/standalone.rs @@ -183,7 +183,14 @@ pub async fn write_standalone_binary( if output.exists() { // If the output is a directory, throw error if output.is_dir() { - bail!("Could not compile: {:?} is a directory.", &output); + bail!( + concat!( + "Could not compile to file '{}' because a directory exists with ", + "the same name. You can use the `--output ` flag to ", + "provide an alternative name." + ), + output.display() + ); } // Make sure we don't overwrite any file not created by Deno compiler. @@ -199,7 +206,14 @@ pub async fn write_standalone_binary( has_trailer = magic_trailer == MAGIC_TRAILER; } if !has_trailer { - bail!("Could not compile: cannot overwrite {:?}.", &output); + bail!( + concat!( + "Could not compile to file '{}' because the file already exists ", + "and cannot be overwritten. Please delete the existing file or ", + "use the `--output ` flag to ", + "provide an alternative name.", + ), + output_base.display(), + ); } tokio::fs::create_dir_all(output_base).await?; } -- cgit v1.2.3