File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 11use core:: ptr:: NonNull ;
22
3- use crate :: rc:: Id ;
3+ use crate :: rc:: { Id , Shared } ;
44use crate :: runtime:: Object ;
5- use objc2_exception:: { r#try, Exception } ;
5+ use objc2_exception:: r#try;
66
77// Comment copied from `objc2_exception`
88
@@ -21,6 +21,8 @@ use objc2_exception::{r#try, Exception};
2121/// undefined behaviour until `C-unwind` is stabilized, see [RFC-2945].
2222///
2323/// [RFC-2945]: https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html
24- pub unsafe fn catch_exception < R > ( closure : impl FnOnce ( ) -> R ) -> Result < R , Id < Exception > > {
25- r#try ( closure) . map_err ( |e| Id :: new ( NonNull :: new ( e) . unwrap ( ) ) )
24+ pub unsafe fn catch_exception < R > (
25+ closure : impl FnOnce ( ) -> R ,
26+ ) -> Result < R , Option < Id < Object , Shared > > > {
27+ r#try ( closure) . map_err ( |e| NonNull :: new ( e) . map ( |e| Id :: new ( e. cast ( ) ) ) )
2628}
Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ macro_rules! objc_try {
1414 ( $b: block) => {
1515 $crate:: exception:: catch_exception( || $b) . map_err( |exception| {
1616 use alloc:: borrow:: ToOwned ;
17- if exception . is_null ( ) {
18- MessageError ( "Uncaught exception nil" . to_owned ( ) )
17+ if let Some ( exception ) = exception {
18+ MessageError ( alloc :: format! ( "Uncaught exception {:?}" , exception ) )
1919 } else {
20- MessageError ( alloc :: format! ( "Uncaught exception {:?}" , & * * exception ) )
20+ MessageError ( "Uncaught exception nil" . to_owned ( ) )
2121 }
2222 } )
2323 } ;
You can’t perform that action at this time.
0 commit comments