contextfree / winrt-rust

Use and (eventually) make Windows Runtime APIs with Rust
Apache License 2.0
142 stars 10 forks source link

Catch panics in event handlers #49

Open Boddlnagg opened 6 years ago

Boddlnagg commented 6 years ago

Panics should generally never cross FFI boundaries (it's undefined behavior according to https://static.rust-lang.org/doc/master/std/panic/fn.catch_unwind.html).

Catch the panic using catch_unwind, and convert it into an appropriate HRESULT value (possibly E_FAIL).