mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
Implement error for remaining errors and the amalgamation error (#184)
This commit is contained in:
parent
39ef47ebb1
commit
b68b109b7d
@ -150,6 +150,39 @@ impl PartialEq for RuntimeError {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RuntimeError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
RuntimeError::IndirectCallSignature { table } => write!(
|
||||
f,
|
||||
"Indirect call signature error with Table Index \"{:?}\"",
|
||||
table
|
||||
),
|
||||
RuntimeError::IndirectCallToNull { table } => {
|
||||
write!(f, "Indirect call to null with table index \"{:?}\"", table)
|
||||
}
|
||||
RuntimeError::IllegalArithmeticOperation => write!(f, "Illegal arithmetic operation"),
|
||||
RuntimeError::OutOfBoundsAccess { memory, addr } => match addr {
|
||||
Some(addr) => write!(
|
||||
f,
|
||||
"Out-of-bounds access with memory index {:?} and address {}",
|
||||
memory, addr
|
||||
),
|
||||
None => write!(f, "Out-of-bounds access with memory index {:?}", memory),
|
||||
},
|
||||
RuntimeError::TableOutOfBounds { table } => {
|
||||
write!(f, "Table out of bounds with table index \"{:?}\"", table)
|
||||
}
|
||||
RuntimeError::Unknown { msg } => {
|
||||
write!(f, "Unknown runtime error with message: \"{}\"", msg)
|
||||
}
|
||||
RuntimeError::User { msg } => write!(f, "User runtime error with message: \"{}\"", msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for RuntimeError {}
|
||||
|
||||
/// This error type is produced by resolving a wasm function
|
||||
/// given its name.
|
||||
///
|
||||
@ -218,6 +251,15 @@ impl PartialEq for CallError {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for CallError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
CallError::Resolve(resolve_error) => write!(f, "Call error: {}", resolve_error),
|
||||
CallError::Runtime(runtime_error) => write!(f, "Call error: {}", runtime_error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// This error type is produced when creating something,
|
||||
/// like a `Memory` or a `Table`.
|
||||
#[derive(Debug, Clone)]
|
||||
@ -311,3 +353,11 @@ impl From<ResolveError> for CallError {
|
||||
CallError::Resolve(resolve_err)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {}
|
||||
|
Loading…
Reference in New Issue
Block a user