cranelift-module: make backend error an anyhow::Error

This allows us to retain richer information from backend errors.
We already have `anyhow` as a dep in several places in the wasmtime
tree, and in cranelift-faerie. faerie is the only user of this
variant.

Existing code that puts a String into the Backend error can trivially
adapt their code to emit an anyhow::Error.
This commit is contained in:
Pat Hickey
2020-03-13 11:34:21 -07:00
parent ec90509387
commit fdfda89d59
2 changed files with 2 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ cranelift-entity = { path = "../entity", version = "0.59.0" }
hashbrown = { version = "0.6", optional = true } hashbrown = { version = "0.6", optional = true }
log = { version = "0.4.6", default-features = false } log = { version = "0.4.6", default-features = false }
thiserror = "1.0.4" thiserror = "1.0.4"
anyhow = "1.0"
[features] [features]
default = ["std"] default = ["std"]

View File

@@ -149,7 +149,7 @@ pub enum ModuleError {
Compilation(#[from] CodegenError), Compilation(#[from] CodegenError),
/// Wraps a generic error from a backend /// Wraps a generic error from a backend
#[error("Backend error: {0}")] #[error("Backend error: {0}")]
Backend(String), Backend(#[source] anyhow::Error),
} }
/// A convenient alias for a `Result` that uses `ModuleError` as the error type. /// A convenient alias for a `Result` that uses `ModuleError` as the error type.