-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Adds host function for handle panicking #7954
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1007,6 +1007,17 @@ trait Allocator { | |
| } | ||
| } | ||
|
|
||
| /// Wasm only panic handler. | ||
| #[runtime_interface(wasm_only)] | ||
| trait PanicHandler { | ||
| /// Should be called when the wasm instance is panicking. | ||
| /// | ||
| /// The given `message` should correspond to the reason the instance panicked. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some points that should be IMO addressed in the docs:
UPD: I also see in the code that if this function was called at least once, then it will return an error, even if there were no traps within the call. That should be either documented as well. Alternatively, we could just give trapping semantics to this call. I.e. when it's called it stashes the message and then traps. UPD2: I see that |
||
| fn panicking(&mut self, message: &str) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe just |
||
| self.instance_panicked(message); | ||
| } | ||
| } | ||
|
|
||
| /// Interface that provides functions for logging from within the runtime. | ||
| #[runtime_interface] | ||
| pub trait Logging { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be just
panickedmaybe?