-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix trap handling, and run trap-test with components
- Loading branch information
Showing
6 changed files
with
110 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,43 @@ | ||
use {super::fastly::api::types, crate::session::Session}; | ||
use { | ||
super::fastly::api::types, | ||
crate::{ | ||
error::{self, HandleError}, | ||
session::Session, | ||
}, | ||
http::header::InvalidHeaderName, | ||
}; | ||
|
||
impl types::Host for Session {} | ||
pub enum TrappableError { | ||
Error(types::Error), | ||
Trap(anyhow::Error), | ||
} | ||
|
||
impl types::Host for Session { | ||
fn convert_error(&mut self, err: TrappableError) -> wasmtime::Result<types::Error> { | ||
match err { | ||
TrappableError::Error(err) => Ok(err), | ||
TrappableError::Trap(err) => Err(err), | ||
} | ||
} | ||
} | ||
|
||
impl From<HandleError> for TrappableError { | ||
fn from(_: HandleError) -> Self { | ||
Self::Error(types::Error::BadHandle) | ||
} | ||
} | ||
|
||
impl From<InvalidHeaderName> for TrappableError { | ||
fn from(_: InvalidHeaderName) -> Self { | ||
Self::Error(types::Error::GenericError) | ||
} | ||
} | ||
|
||
impl From<error::Error> for TrappableError { | ||
fn from(e: error::Error) -> Self { | ||
match e { | ||
error::Error::FatalError(_) => Self::Trap(anyhow::anyhow!(e.to_string())), | ||
_ => Self::Error(e.into()), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters