Skip to content

Commit 74dda7a

Browse files
committed
Update documentation on catch-all to say that it doesn't affect UB
1 parent 76567af commit 74dda7a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

crates/objc2/src/exception.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
//! # `@throw` and `@try/@catch` exceptions.
22
//!
3-
//! By default, if the [`msg_send!`] macro causes an exception to be thrown,
4-
//! this will unwind into Rust, resulting in undefined behavior. However, this
5-
//! crate has an `"catch-all"` feature which, when enabled, wraps each
6-
//! [`msg_send!`] in a `@catch` and panics if an exception is caught,
7-
//! preventing Objective-C from unwinding into Rust.
3+
//! By default, if a message send (such as those generated with the
4+
//! [`msg_send!`] and [`extern_methods!`] macros) causes an exception to be
5+
//! thrown, `objc2` will simply let it unwind into Rust.
6+
//!
7+
//! While not UB, it will likely end up aborting the process, since Rust
8+
//! cannot catch foreign exceptions like Objective-C's. However, `objc2` has
9+
//! the `"catch-all"` Cargo feature, which, when enabled, wraps each message
10+
//! send in a `@catch` and instead panics if an exception is caught, which
11+
//! might lead to slightly better error messages.
812
//!
913
//! Most of the functionality in this module is only available when the
1014
//! `"exception"` feature is enabled.

0 commit comments

Comments
 (0)