Stream: git-wasmtime

Topic: wasmtime / PR #3033 Give accessors to `wasmtime::Trap` ca...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 25 2021 at 09:51):

bnjbvr opened PR #3033 from trap-errors to main:

It wasn't possible to just retrieve a user-created error description in wasmtime::Trap (i.e. created with wasmtime::Trap::new("hi there")). This user message would only show up as part of the full Display impl for Trap, which also prints out the unmangled backtrace and other information. A first commit adds a user_message() accessor to retrieve it, if it was set.

As I was trying to find another way to get a custom error message, I saw that Trap implemented std::error::Error if the trap was created from an StdError. Unfortunately, it doesn't give access to it directly either, but it gives access to the underlying source() of the error itself. It would be nice to have access to the error itself, to not lose one layer of error information. As a result, I've tweaked source() so it returns the error that was used to create the trap, and not the error's source directly. Conceptually it makes sense that the first source of the trap is the error that it was converted from, but it would also be reasonable to say that the trap is the error (so instead, we could just add another accessor to get the error). Discuss. :)

view this post on Zulip Wasmtime GitHub notifications bot (Jun 25 2021 at 15:56):

bnjbvr updated PR #3033 from trap-errors to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 25 2021 at 16:00):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 25 2021 at 16:00):

alexcrichton created PR review comment:

Could this return impl Display so if necessary we can change this in the future to returning something that isn't necessarily stored on Self?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 25 2021 at 16:00):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 25 2021 at 16:00):

alexcrichton created PR review comment:

Could this elaborate a bit on what the method does? For example I think this should explain how this is different from Display for Trap and an example situation you might end up using this.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 28 2021 at 10:10):

bnjbvr updated PR #3033 from trap-errors to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 30 2021 at 14:34):

alexcrichton merged PR #3033.


Last updated: Dec 23 2024 at 12:05 UTC