change crate config error naming, improve error message content

master
Noah Lemen 7 years ago
parent ee29ab2a76
commit 2cb292164c
  1. 10
      src/error.rs
  2. 4
      src/manifest.rs

@ -16,7 +16,7 @@ pub enum Error {
#[fail(display = "{}. stderr:\n\n{}", message, stderr)] #[fail(display = "{}. stderr:\n\n{}", message, stderr)]
Cli { message: String, stderr: String }, Cli { message: String, stderr: String },
#[fail(display = "{}", message)] #[fail(display = "{}", message)]
Config { message: String }, CrateConfig { message: String },
} }
impl Error { impl Error {
@ -27,8 +27,8 @@ impl Error {
}) })
} }
pub fn config(message: &str) -> Result<(), Self> { pub fn crate_config(message: &str) -> Result<(), Self> {
Err(Error::Config { Err(Error::CrateConfig {
message: message.to_string(), message: message.to_string(),
}) })
} }
@ -42,7 +42,9 @@ impl Error {
message: _, message: _,
stderr: _, stderr: _,
} => "There was an error while calling another CLI tool. Details:\n\n", } => "There was an error while calling another CLI tool. Details:\n\n",
Error::Config { message: _ } => "There was a configuration error. Details:\n\n", Error::CrateConfig { message: _ } => {
"There was a crate configuration error. Details:\n\n"
}
}.to_string() }.to_string()
} }
} }

@ -153,7 +153,9 @@ fn has_cdylib(path: &str) -> Result<bool, Error> {
pub fn check_crate_type(path: &str) -> Result<(), Error> { pub fn check_crate_type(path: &str) -> Result<(), Error> {
if !has_cdylib(path)? { if !has_cdylib(path)? {
Error::config("crate-type must include cdylib to compile to wasm32-unknown-unknown") Error::crate_config(
"crate-type must include cdylib to compile to wasm32-unknown-unknown. Add the following to your Cargo.toml file:\n\n[lib]\ncrate-type = [\"cdylib\"]"
)
} else { } else {
Ok(()) Ok(())
} }

Loading…
Cancel
Save