History log of /wasmtime-44.0.1/crates/wasi-common/src/error.rs (Results 1 – 25 of 29)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: dev, v36.0.9, v44.0.1, v43.0.2, v36.0.8, v24.0.8, v44.0.0, v43.0.1, v42.0.2, v36.0.7, v24.0.7, v43.0.0, v42.0.1, v41.0.4, v42.0.0, v40.0.4, v36.0.6, v24.0.6, v41.0.3, v41.0.2, v41.0.1, v36.0.5, v40.0.3, v41.0.0, v36.0.4, v39.0.2, v40.0.2
# 05a041c2 08-Jan-2026 Nick Fitzgerald <[email protected]>

Migrate wasi-common to `wasmtime::error` (#12293)

* Migrate wiggle and wiggle generate to `wasmtime::error`

* Fix testing `wiggle` and `wiggle-test` in isolation

When doing plain old `cargo test -

Migrate wasi-common to `wasmtime::error` (#12293)

* Migrate wiggle and wiggle generate to `wasmtime::error`

* Fix testing `wiggle` and `wiggle-test` in isolation

When doing plain old `cargo test -p wiggle` (or `wiggle-test`) the test would
fail due to linking errors because Wasmtime's `std` cargo feature (and maybe
others) wasn't being enabled. The crate's tests would pass when run as part of
the whole workspace, however, because of cargo feature resolution and other
crates that enabled the necessary features, which is why CI is green.

* Remove direct anyhow dependency in wiggle-test

* Migrate wasi-nn to `wasmtime::error`

* Migrate wasi-keyvalue to `wasmtime::error`

* Migrate wasi-io to `wasmtime::error`

* Migrate wasi-http to `wasmtime::error`

* Migrate wasi-config to `wasmtime::error`

* Migrate wasi-common to `wastime::error`

This is another interesting one because wasi-common is used internally to
Wasmtime but also by other projects. Therefore, rather than using
`wastime::error::*` and making `wasmtime` a hard dependency, we use just
`wasmtime_environ::error`.

* cargo fmt

show more ...


Revision tags: v40.0.1, v40.0.0, v39.0.1, v39.0.0, v38.0.4, v37.0.3, v36.0.3, v24.0.5, v38.0.3, v38.0.2, v38.0.1, v37.0.2, v37.0.1, v37.0.0, v36.0.2, v36.0.1, v36.0.0, v35.0.0, v24.0.4, v33.0.2, v34.0.2, v34.0.1, v33.0.1, v24.0.3, v32.0.1, v34.0.0, v33.0.0, v32.0.0, v31.0.0, v30.0.2, v30.0.1, v30.0.0, v29.0.1, v29.0.0, v28.0.1, v28.0.0, v27.0.0, v26.0.1, v25.0.3, v24.0.2, v26.0.0, v21.0.2, v22.0.1, v23.0.3, v25.0.2, v24.0.1, v25.0.1, v25.0.0, v24.0.0, v23.0.2, v23.0.1, v23.0.0, v22.0.0, v21.0.1, v21.0.0, v20.0.2, v20.0.1, v20.0.0, v17.0.3, v19.0.2, v18.0.4, v19.0.1, v19.0.0, v18.0.3, v18.0.2, v17.0.2, v18.0.1, v18.0.0, v17.0.1, v17.0.0, v16.0.0
# 3b61c511 08-Dec-2023 Pat Hickey <[email protected]>

Move wasmtime-wasi's Table to wasmtime::component::ResourceTable (#7655)

* rename to ResourceTable, docs, and export

* wasi: use the table from wasmtime::component

* wasi-http: use wasmtime::compo

Move wasmtime-wasi's Table to wasmtime::component::ResourceTable (#7655)

* rename to ResourceTable, docs, and export

* wasi: use the table from wasmtime::component

* wasi-http: use wasmtime::component's resource table now

* rename file (somehow got lost)

* wasmtime-cli: fixes for resourcetable

* fix wasi-http tests

* more test fixes

* error messages

* fix warning

* cli: fix min build

prtest:full

show more ...


Revision tags: v15.0.1, v15.0.0, v14.0.4, v14.0.3, v14.0.2, v13.0.1, v14.0.1, v14.0.0, minimum-viable-wasi-proxy-serve, v13.0.0, v12.0.2, v11.0.2, v10.0.2, v12.0.1, v12.0.0, v11.0.1, v11.0.0, v10.0.1, v10.0.0, v9.0.4, v9.0.3, v9.0.2, v9.0.1, v9.0.0, v6.0.2, v7.0.1, v8.0.1, v8.0.0, v7.0.0, v6.0.1, v5.0.1, v4.0.1, v6.0.0, v5.0.0, v4.0.0, v3.0.1, v3.0.0
# 56daa8a1 17-Nov-2022 Pat Hickey <[email protected]>

Use wiggle "trappable error" to implement wasi-common (#5279)

* convert wasi-common from defining its own error to using wiggle trappable error

* wasi-common impl crates: switch error strategy

Use wiggle "trappable error" to implement wasi-common (#5279)

* convert wasi-common from defining its own error to using wiggle trappable error

* wasi-common impl crates: switch error strategy

* wasmtime-wasi: error is trappable, and no longer requires UserErrorConversion

* docs

* typo

* readdir: windows fixes

* fix windows scheduler errors

fun fact! the Send and Recv errors here that just had a `.context` on
them were previously not being captured in the downcasting either. They
need to be traps, and would have ended up that way by ommission, but
you'd never actually know that by reading the code!

show more ...


Revision tags: v1.0.2, v2.0.2
# 2afaac51 02-Nov-2022 Alex Crichton <[email protected]>

Return `anyhow::Error` from host functions instead of `Trap`, redesign `Trap` (#5149)

* Return `anyhow::Error` from host functions instead of `Trap`

This commit refactors how errors are modeled w

Return `anyhow::Error` from host functions instead of `Trap`, redesign `Trap` (#5149)

* Return `anyhow::Error` from host functions instead of `Trap`

This commit refactors how errors are modeled when returned from host
functions and additionally refactors how custom errors work with `Trap`.
At a high level functions in Wasmtime that previously worked with
`Result<T, Trap>` now work with `Result<T>` instead where the error is
`anyhow::Error`. This includes functions such as:

* Host-defined functions in a `Linker<T>`
* `TypedFunc::call`
* Host-related callbacks like call hooks

Errors are now modeled primarily as `anyhow::Error` throughout Wasmtime.
This subsequently removes the need for `Trap` to have the ability to
represent all host-defined errors as it previously did. Consequently the
`From` implementations for any error into a `Trap` have been removed
here and the only embedder-defined way to create a `Trap` is to use
`Trap::new` with a custom string.

After this commit the distinction between a `Trap` and a host error is
the wasm backtrace that it contains. Previously all errors in host
functions would flow through a `Trap` and get a wasm backtrace attached
to them, but now this only happens if a `Trap` itself is created meaning
that arbitrary host-defined errors flowing from a host import to the
other side won't get backtraces attached. Some internals of Wasmtime
itself were updated or preserved to use `Trap::new` to capture a
backtrace where it seemed useful, such as when fuel runs out.

The main motivation for this commit is that it now enables hosts to
thread a concrete error type from a host function all the way through to
where a wasm function was invoked. Previously this could not be done
since the host error was wrapped in a `Trap` that didn't provide the
ability to get at the internals.

A consequence of this commit is that when a host error is returned that
isn't a `Trap` we'll capture a backtrace and then won't have a `Trap` to
attach it to. To avoid losing the contextual information this commit
uses the `Error::context` method to attach the backtrace as contextual
information to ensure that the backtrace is itself not lost.

This is a breaking change for likely all users of Wasmtime, but it's
hoped to be a relatively minor change to workaround. Most use cases can
likely change `-> Result<T, Trap>` to `-> Result<T>` and otherwise
explicit creation of a `Trap` is largely no longer necessary.

* Fix some doc links

* add some tests and make a backtrace type public (#55)

* Trap: avoid a trailing newline in the Display impl

which in turn ends up with three newlines between the end of the
backtrace and the `Caused by` in the anyhow Debug impl

* make BacktraceContext pub, and add tests showing downcasting behavior of anyhow::Error to traps or backtraces

* Remove now-unnecesary `Trap` downcasts in `Linker::module`

* Fix test output expectations

* Remove `Trap::i32_exit`

This commit removes special-handling in the `wasmtime::Trap` type for
the i32 exit code required by WASI. This is now instead modeled as a
specific `I32Exit` error type in the `wasmtime-wasi` crate which is
returned by the `proc_exit` hostcall. Embedders which previously tested
for i32 exits now downcast to the `I32Exit` value.

* Remove the `Trap::new` constructor

This commit removes the ability to create a trap with an arbitrary error
message. The purpose of this commit is to continue the prior trend of
leaning into the `anyhow::Error` type instead of trying to recreate it
with `Trap`. A subsequent simplification to `Trap` after this commit is
that `Trap` will simply be an `enum` of trap codes with no extra
information. This commit is doubly-motivated by the desire to always use
the new `BacktraceContext` type instead of sometimes using that and
sometimes using `Trap`.

Most of the changes here were around updating `Trap::new` calls to
`bail!` calls instead. Tests which assert particular error messages
additionally often needed to use the `:?` formatter instead of the `{}`
formatter because the prior formats the whole `anyhow::Error` and the
latter only formats the top-most error, which now contains the
backtrace.

* Merge `Trap` and `TrapCode`

With prior refactorings there's no more need for `Trap` to be opaque or
otherwise contain a backtrace. This commit parse down `Trap` to simply
an `enum` which was the old `TrapCode`. All various tests and such were
updated to handle this.

The main consequence of this commit is that all errors have a
`BacktraceContext` context attached to them. This unfortunately means
that the backtrace is printed first before the error message or trap
code, but given all the prior simplifications that seems worth it at
this time.

* Rename `BacktraceContext` to `WasmBacktrace`

This feels like a better name given how this has turned out, and
additionally this commit removes having both `WasmBacktrace` and
`BacktraceContext`.

* Soup up documentation for errors and traps

* Fix build of the C API

Co-authored-by: Pat Hickey <[email protected]>

show more ...


Revision tags: v2.0.1, v2.0.0
# 24da5f77 05-Oct-2022 Dan Gohman <[email protected]>

Tidy up the WASI `ErrorKind` enum. (#5015)

* Tidy up the WASI `ErrorKind` enum.

`ErrorKind` is an internal enum used in wasi-libc to represent WASI
errors that aren't precisely represened by `st

Tidy up the WASI `ErrorKind` enum. (#5015)

* Tidy up the WASI `ErrorKind` enum.

`ErrorKind` is an internal enum used in wasi-libc to represent WASI
errors that aren't precisely represened by `std::io::ErrorKind` errors.
Add a descriptive comment, and remove some codes that are no longer
needed:

- Remove `NotCapable`, which is no longer used.
- Remove `WouldBlk`, `Exist`, `Noent`, and `Inval`, which have
one-to-one correspondences with codes in `std::io::ErrorKind`.

This will simplify the error handling in #4947 and #4967, as it means
the code will no longer have to check for two different forms of these
errors.

* Map `std::io::ErrorKind::InvalidInput` to `Ok(types::Errno::Inval)`.

show more ...


# d986b3cb 04-Oct-2022 Nathaniel McCallum <[email protected]>

feat: improve wasi_common::ErrorKind derives (#5006)

Besides the standard traits (Copy, Clone, PartialEq and Eq), we also mark
the trait as non-exhaustive so that we can add errors in the future
w

feat: improve wasi_common::ErrorKind derives (#5006)

Besides the standard traits (Copy, Clone, PartialEq and Eq), we also mark
the trait as non-exhaustive so that we can add errors in the future
without breaking API.

Signed-off-by: Nathaniel McCallum <[email protected]>

Signed-off-by: Nathaniel McCallum <[email protected]>

show more ...


Revision tags: v1.0.1, v1.0.0, v0.40.1, v0.40.0
# 918debfe 10-Aug-2022 Dan Gohman <[email protected]>

Stop returning `NOTCAPABLE` errors from WASI calls. (#4666)

* Stop returning `NOTCAPABLE` errors from WASI calls.

`ENOTCAPABLE` was an error code that is used as part of the rights
system, from

Stop returning `NOTCAPABLE` errors from WASI calls. (#4666)

* Stop returning `NOTCAPABLE` errors from WASI calls.

`ENOTCAPABLE` was an error code that is used as part of the rights
system, from CloudABI. There is a set of flags associated with each file
descriptor listing which operations can be performed with the file
descriptor, and if an attempt is made to perform an operation with a
file descriptor that isn't permitted by its rights flags, it fails with
`ENOTCAPABLE`.

WASI is removing the rights system. For example, WebAssembly/wasi-libc#294
removed support for translating `ENOTCAPABLE` into POSIX error codes, on
the assumption that engines should stop using it.

So as another step to migrating away from the rights system, remove uses
of the `ENOTCAPABLE` error.

* Update crates/wasi-common/src/file.rs

Co-authored-by: Jamey Sharp <[email protected]>

* Update crates/wasi-common/src/dir.rs

Co-authored-by: Jamey Sharp <[email protected]>

Co-authored-by: Jamey Sharp <[email protected]>

show more ...


Revision tags: v0.39.1, v0.38.3, v0.38.2, v0.39.0, v0.38.1, v0.38.0, v0.37.0, v0.36.0, v0.35.3, v0.34.2, v0.35.2, v0.35.1, v0.35.0, v0.33.1, v0.34.1, v0.34.0
# 853a0256 21-Jan-2022 Harald Hoyer <[email protected]>

Implement `sock_accept`

With the addition of `sock_accept()` in `wasi-0.11.0`, wasmtime can now
implement basic networking for pre-opened sockets.

For Windows `AsHandle` was replaced with `AsRawHan

Implement `sock_accept`

With the addition of `sock_accept()` in `wasi-0.11.0`, wasmtime can now
implement basic networking for pre-opened sockets.

For Windows `AsHandle` was replaced with `AsRawHandleOrSocket` to cope
with the duality of Handles and Sockets.

For Unix a `wasi_cap_std_sync::net::Socket` enum was created to handle
the {Tcp,Unix}{Listener,Stream} more efficiently in
`WasiCtxBuilder::preopened_socket()`.

The addition of that many `WasiFile` implementors was mainly necessary,
because of the difference in the `num_ready_bytes()` function.

A known issue is Windows now busy polling on sockets, because except
for `stdin`, nothing is querying the status of windows handles/sockets.

Another know issue on Windows, is that there is no crate providing
support for `fcntl(fd, F_GETFL, 0)` on a socket.

Signed-off-by: Harald Hoyer <[email protected]>

show more ...


Revision tags: v0.33.0, v0.32.1, v0.32.0, v0.31.0, v0.30.0, v0.29.0, v0.28.0, v0.26.1, v0.27.0
# b7efcbe8 29-Apr-2021 Pat Hickey <[email protected]>

jump through enough hoops for the poll lifetime to work out

you program rust for a few years and you think you're done tearing your
hair out over lifetimes, well, you'll find yourself wrong


Revision tags: v0.26.0, v0.25.0, v0.24.0, v0.23.0
# 7daa7763 02-Feb-2021 Pat Hickey <[email protected]>

rustdoc the errors


# e940d31f 30-Jan-2021 Pat Hickey <[email protected]>

add a noent / not_found errorkind


# 47fec44c 28-Jan-2021 Pat Hickey <[email protected]>

move wasi-c2 into wasi-common


Revision tags: v0.22.1, cranelift-v0.69.0, v0.22.0
# b149a03d 07-Jan-2021 Pat Hickey <[email protected]>

wasi-common: instead of panicking, use an Error::Unsupported that Traps


Revision tags: v0.21.0, v0.20.0
# e8c01dde 19-Aug-2020 Pat Hickey <[email protected]>

put getrandom::Error into Error


# c1aec81b 19-Aug-2020 Pat Hickey <[email protected]>

add enough errno variants to cover all windows codes too


# 4535741d 19-Aug-2020 Pat Hickey <[email protected]>

refactor when we translate io::Error to an Error

* a certain subset of io::Errors are expected - these we have
a (platform-specific, because windows) method to translate into
one of the wasi err

refactor when we translate io::Error to an Error

* a certain subset of io::Errors are expected - these we have
a (platform-specific, because windows) method to translate into
one of the wasi errno variants in the Error enum.
* some io::Errors are unexpected - wasi-common doesnt expect them from
the underlying OS. rather than preserve any fidelity in reporting
those to the user (only the unix impl attempts this), lets collect
those as an `Error::UnexpectedIo(#[source] std::io::Error)`.
Rather than trace at the conversion site, we rely on the wiggle error
conversion hooks to trace the `Error`'s `Debug` impl, and then
we convert all of these unexpected into `Errno::Io` for returning
to the guest.

This is a different behavior from before, and I don't have any firm
guarantees that nobody was depending on the old behavior, but it
appears to me that none of those unexpected errnos were reasonable
to expect from any of the filesystem syscalls wasi-common is making.

show more ...


# e8160c9a 18-Aug-2020 Pat Hickey <[email protected]>

redefine crate to use `Error` everywhere except in `wasi`


# b8409dd9 18-Aug-2020 Pat Hickey <[email protected]>

wasi-common: define an Error type for the crate


Revision tags: v0.19.0, v0.18.0, v0.17.0, v0.16.0, v0.15.0, cranelift-v0.62.0, cranelift-v0.61.0, cranelift-v0.60.0
# 135a48ca 05-Mar-2020 Jakub Konka <[email protected]>

wasi-common error cleanup: part 1, yanix (#1226)

* Reuse std::io::Error for raw *nix errno

This commit removes custom `yanix::Errno` and instead (as was
previously suggested) reuses `std::io::Er

wasi-common error cleanup: part 1, yanix (#1226)

* Reuse std::io::Error for raw *nix errno

This commit removes custom `yanix::Errno` and instead (as was
previously suggested) reuses `std::io::Error` to generate and wrap
raw *nix errno value.

* Update wasi-common to use new Yanix error type

This commit updates `wasi-common` to use new way of handling raw
OS error in `yanix`; i.e., via re-use of `std::io::Error` instead
of a custom `Errno` enum.

* Fix formatting

* Unwrap if io::Error created from raw OS error

This commit calls `unwrap` on `err` if that one was created via
`io::Error::last_os_error()`. It also refactors error matching
in several syscalls on the BSD platform (mainly).

show more ...


Revision tags: v0.12.0, v0.11.0, v0.10.0
# 5b5f9a7b 17-Jan-2020 Marcin Mielniczuk <[email protected]>

Properly return errors.


# 5f1c0eb8 16-Jan-2020 Jakub Konka <[email protected]>

Generate strerror from witx; tweak Display for WasiError (#832)

This commit introduces two small changes:
* it adds `gen_errno_strerror` to `wig` crate which generates a
`strerror` function for

Generate strerror from witx; tweak Display for WasiError (#832)

This commit introduces two small changes:
* it adds `gen_errno_strerror` to `wig` crate which generates a
`strerror` function for `__wasi_errno_t` directly from `*.witx`,
similarly to how it's done in the `wasi` crate
* it tweaks `WasiError` type to include the error message generated
with `strerror` when displaying the error

show more ...


# e474a9e8 16-Jan-2020 Jakub Konka <[email protected]>

[wasi-common] Log string representation of WASI errno at the trace level (#760)

* Log str repr of WASI errno at trace level

This commit refactors `Error` enum, and adds logging of the WASI
errno

[wasi-common] Log string representation of WASI errno at the trace level (#760)

* Log str repr of WASI errno at trace level

This commit refactors `Error` enum, and adds logging of the WASI
errno string representation at the trace level. Now, when tracing
WASI syscalls, we will be greeted with a nicely formatted errno
value after each syscall:

```
path_open(...)
| *fd=5
| errno=ESUCCESS
```

This commit gets rid of `errno_from_nix`, `errno_from_win` and
`errno_from_host` helper fns in favour of direct `From` implementations
for the relevant types such as `yanix::Errno` and `winx::winerror::WinError`.
`errno_from_host` is replaced by a trait `FromRawOsError`.

* Back port changes to snapshot0

* Fix indentation in logs

show more ...


Revision tags: v0.9.0
# 98e84ae4 08-Dec-2019 Marcin Mielniczuk <[email protected]>

Refactor poll_oneoff and return stdin if immediately readable.


# e674eee6 06-Jan-2020 Jakub Konka <[email protected]>

[wasi-common] Use thiserror proc macros for auto From impls (#758)

* Use thiserror proc macros for auto From impls

This commit refactors `wasi_common::error::Error` by using `#[from]`
proc macro

[wasi-common] Use thiserror proc macros for auto From impls (#758)

* Use thiserror proc macros for auto From impls

This commit refactors `wasi_common::error::Error` by using `#[from]`
proc macro to autoderive `From` for wrapped errors.

* Back port changes to snapshot0

* Auto impl Display for WasiError

* Fix stack overflow when auto generating Display for WasiError

show more ...


# 95c2addf 12-Dec-2019 Jakub Konka <[email protected]>

Compile wasi-common to Emscripten (#688)

* Compile wasi-common to Emscripten

This commit enables cross-compiling of `wasi-common` to Emscripten. To achieve
this, this commit does quite a bit res

Compile wasi-common to Emscripten (#688)

* Compile wasi-common to Emscripten

This commit enables cross-compiling of `wasi-common` to Emscripten. To achieve
this, this commit does quite a bit reshuffling in the existing codebase. Namely,
* rename `linux` modules in `wasi-common` and `yanix` to `linux_like` -- this is
needed so that we can separate out logic specific to Linux and Emscripten out
* tweak `dir` module in `yanix` to support Emscripten -- in particular, the main
change involves `SeekLoc::from_raw` which has to be now host-specific, and is now
fallible
* tweak `filetime` so that in Emscripten we never check for existence of `utimensat`
at runtime since we are guaranteed for it to exist by design
* since `utimes` and `futimes` are not present in Emscripten, move them into a separate
module, `utimesat`, and tag it cfg-non-emscripten only
* finally, `to_timespec` is now fallible since on Emscripten we have to cast number of
seconds, `FileTime::seconds` from `i64` to `libc::c_long` which resolves to `i32`
unlike on other nixes

* Fix macos build

* Verify wasi-common compiles to Emscripten

This commit adds `emscripten` job to Github Actions which installs
`wasm32-unknown-emscripten` target, and builds `wasi-common` crate.

* Use #[path] to cherry-pick mods for Emscripten

This commit effectively reverses the reorg introduced in 145f4a5
in that it ditches `linux_like` mod for separate mods `linux` and
`emscripten` which are now on the same crate level, and instead,
pulls in common bits from `linux` using the `#[path = ..]` proc
macro.

show more ...


12