mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-17 10:51:21 +00:00
Remove WasmTrapInfo
and passExceptionCode
in the generic Box<Any>
container.
This commit is contained in:
@ -179,18 +179,7 @@ impl std::error::Error for LinkError {}
|
||||
/// The main way to do this is `Instance.call`.
|
||||
///
|
||||
/// Comparing two `RuntimeError`s always evaluates to false.
|
||||
pub enum RuntimeError {
|
||||
/// Trap.
|
||||
Trap {
|
||||
/// Trap message.
|
||||
msg: Box<str>,
|
||||
},
|
||||
/// Error.
|
||||
Error {
|
||||
/// Error data.
|
||||
data: Box<dyn Any + Send>,
|
||||
},
|
||||
}
|
||||
pub struct RuntimeError(pub Box<dyn Any + Send>);
|
||||
|
||||
impl PartialEq for RuntimeError {
|
||||
fn eq(&self, _other: &RuntimeError) -> bool {
|
||||
@ -200,21 +189,15 @@ impl PartialEq for RuntimeError {
|
||||
|
||||
impl std::fmt::Display for RuntimeError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
RuntimeError::Trap { ref msg } => {
|
||||
write!(f, "WebAssembly trap occurred during runtime: {}", msg)
|
||||
}
|
||||
RuntimeError::Error { data } => {
|
||||
if let Some(s) = data.downcast_ref::<String>() {
|
||||
write!(f, "\"{}\"", s)
|
||||
} else if let Some(s) = data.downcast_ref::<&str>() {
|
||||
write!(f, "\"{}\"", s)
|
||||
} else if let Some(exc_code) = data.downcast_ref::<ExceptionCode>() {
|
||||
write!(f, "Caught exception of type \"{:?}\".", exc_code)
|
||||
} else {
|
||||
write!(f, "unknown error")
|
||||
}
|
||||
}
|
||||
let data = &*self.0;
|
||||
if let Some(s) = data.downcast_ref::<String>() {
|
||||
write!(f, "\"{}\"", s)
|
||||
} else if let Some(s) = data.downcast_ref::<&str>() {
|
||||
write!(f, "\"{}\"", s)
|
||||
} else if let Some(exc_code) = data.downcast_ref::<ExceptionCode>() {
|
||||
write!(f, "Caught exception of type \"{:?}\".", exc_code)
|
||||
} else {
|
||||
write!(f, "unknown error")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user