Module exception

Module exception 

Source
Expand description

§@throw and @try/@catch exceptions.

By default, if a message send (such as those generated with the msg_send! and extern_methods! macros) causes an exception to be thrown, objc2 will simply let it unwind into Rust.

While not UB, it will likely end up aborting the process, since Rust cannot catch foreign exceptions like Objective-C’s. However, objc2 has the "catch-all" Cargo feature, which, when enabled, wraps each message send in a @catch and instead panics if an exception is caught, which might lead to slightly better error messages.

Most of the functionality in this module is only available when the "exception" feature is enabled.

See the following links for more information:

Structs§

Exception
An Objective-C exception.

Functions§

catchexception
Tries to execute the given closure and catches an Objective-C exception if one is thrown.
throwexception
Throws an Objective-C exception.