wasi-common: port to use wiggle::Trap
This commit is contained in:
@@ -714,10 +714,13 @@ impl<'a> WasiSnapshotPreview1 for WasiCtx {
|
||||
Ok(nevents)
|
||||
}
|
||||
|
||||
fn proc_exit(&self, _rval: types::Exitcode) -> std::result::Result<(), ()> {
|
||||
// proc_exit is special in that it's expected to unwind the stack, which
|
||||
// typically requires runtime-specific logic.
|
||||
unimplemented!("runtimes are expected to override this implementation")
|
||||
fn proc_exit(&self, status: types::Exitcode) -> wiggle::Trap {
|
||||
// Check that the status is within WASI's range.
|
||||
if status < 126 {
|
||||
wiggle::Trap::I32(status as i32)
|
||||
} else {
|
||||
wiggle::Trap::String("exit with invalid exit status outside of [0..126)".to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
fn proc_raise(&self, _sig: types::Signal) -> Result<()> {
|
||||
|
||||
@@ -23,7 +23,7 @@ impl types::GuestErrorConversion for WasiCtx {
|
||||
}
|
||||
|
||||
impl types::UserErrorConversion for WasiCtx {
|
||||
fn errno_from_error(&self, e: Error) -> Result<Errno, String> {
|
||||
fn errno_from_error(&self, e: Error) -> Result<Errno, wiggle::Trap> {
|
||||
tracing::debug!("Error: {:?}", e);
|
||||
Ok(e.into())
|
||||
}
|
||||
@@ -346,7 +346,7 @@ impl wasi_unstable::WasiUnstable for WasiCtx {
|
||||
Ok(nevents)
|
||||
}
|
||||
|
||||
fn proc_exit(&self, rval: Exitcode) -> Result<(), ()> {
|
||||
fn proc_exit(&self, rval: Exitcode) -> wiggle::Trap {
|
||||
WasiSnapshotPreview1::proc_exit(self, rval)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ impl types::GuestErrorConversion for WasiCtx {
|
||||
}
|
||||
|
||||
impl types::UserErrorConversion for WasiCtx {
|
||||
fn errno_from_error(&self, e: Error) -> Result<Errno, String> {
|
||||
fn errno_from_error(&self, e: Error) -> Result<Errno, wiggle::Trap> {
|
||||
debug!("Error: {:?}", e);
|
||||
Ok(e.into())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user