Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce duplication in error messages #532

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/environ/src/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ pub type Traps = PrimaryMap<DefinedFuncIndex, Vec<TrapInformation>>;
#[derive(Error, Debug)]
pub enum CompileError {
/// A wasm translation error occured.
#[error("WebAssembly translation error: {0}")]
#[error("WebAssembly translation error")]
Wasm(#[from] WasmError),

/// A compilation error occured.
#[error("Compilation error: {0}")]
#[error("Compilation error")]
Codegen(#[from] CodegenError),

/// A compilation error occured.
Expand Down
2 changes: 1 addition & 1 deletion crates/jit/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub enum ActionOutcome {
#[derive(Error, Debug)]
pub enum ActionError {
/// An internal implementation error occurred.
#[error("{0}")]
#[error("Failed to setup a module")]
Setup(#[from] SetupError),

/// No field with the specified name was present.
Expand Down
4 changes: 2 additions & 2 deletions crates/jit/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ pub struct UnknownInstance {
#[derive(Error, Debug)]
pub enum ContextError {
/// An unknown instance name was used.
#[error("{0}")]
#[error("An error occured due to an unknown instance being specified")]
Instance(#[from] UnknownInstance),
/// An error occured while performing an action.
#[error("{0}")]
#[error("An error occurred while performing an action")]
Action(#[from] ActionError),
}

Expand Down
4 changes: 2 additions & 2 deletions crates/jit/src/instantiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ pub enum SetupError {
Validate(String),

/// A wasm translation error occured.
#[error("WebAssembly compilation error: {0}")]
#[error("WebAssembly failed to compile")]
Compile(#[from] CompileError),

/// Some runtime resource was unavailable or insufficient, or the start function
/// trapped.
#[error("Instantiation error: {0}")]
#[error("Instantiation failed during setup")]
Instantiate(#[from] InstantiationError),

/// Debug information generation error occured.
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ pub enum InstantiationError {
Resource(String),

/// A wasm link error occured.
#[error("{0}")]
#[error("Failed to link module")]
Link(#[from] LinkError),

/// A compilation error occured.
Expand Down
6 changes: 3 additions & 3 deletions crates/wast/src/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl WastContext {
Ok(()) => bail!("{}\nexpected module to fail to build", context(span)),
Err(e) => e,
};
let error_message = err.to_string();
let error_message = format!("{:?}", err);
if !error_message.contains(&message) {
// TODO: change to bail!
println!(
Expand Down Expand Up @@ -339,7 +339,7 @@ impl WastContext {
}
Err(e) => e,
};
let error_message = err.to_string();
let error_message = format!("{:?}", err);
if !error_message.contains(&message) {
// TODO: change to bail!
println!(
Expand All @@ -360,7 +360,7 @@ impl WastContext {
Ok(()) => bail!("{}\nexpected module to fail to link", context(span)),
Err(e) => e,
};
let error_message = err.to_string();
let error_message = format!("{:?}", err);
if !error_message.contains(&message) {
bail!(
"{}\nassert_unlinkable: expected {}, got {}",
Expand Down