Skip to content

Commit 2cb2921

Browse files
committed
change crate config error naming, improve error message content
1 parent ee29ab2 commit 2cb2921

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/error.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub enum Error {
1616
#[fail(display = "{}. stderr:\n\n{}", message, stderr)]
1717
Cli { message: String, stderr: String },
1818
#[fail(display = "{}", message)]
19-
Config { message: String },
19+
CrateConfig { message: String },
2020
}
2121

2222
impl Error {
@@ -27,8 +27,8 @@ impl Error {
2727
})
2828
}
2929

30-
pub fn config(message: &str) -> Result<(), Self> {
31-
Err(Error::Config {
30+
pub fn crate_config(message: &str) -> Result<(), Self> {
31+
Err(Error::CrateConfig {
3232
message: message.to_string(),
3333
})
3434
}
@@ -42,7 +42,9 @@ impl Error {
4242
message: _,
4343
stderr: _,
4444
} => "There was an error while calling another CLI tool. Details:\n\n",
45-
Error::Config { message: _ } => "There was a configuration error. Details:\n\n",
45+
Error::CrateConfig { message: _ } => {
46+
"There was a crate configuration error. Details:\n\n"
47+
}
4648
}.to_string()
4749
}
4850
}

src/manifest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ fn has_cdylib(path: &str) -> Result<bool, Error> {
153153

154154
pub fn check_crate_type(path: &str) -> Result<(), Error> {
155155
if !has_cdylib(path)? {
156-
Error::config("crate-type must include cdylib to compile to wasm32-unknown-unknown")
156+
Error::crate_config(
157+
"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\"]"
158+
)
157159
} else {
158160
Ok(())
159161
}

0 commit comments

Comments
 (0)