File tree 2 files changed +9
-7
lines changed
2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 1
1
use core:: ptr:: NonNull ;
2
2
3
- use crate :: rc:: Id ;
3
+ use crate :: rc:: { Id , Shared } ;
4
4
use crate :: runtime:: Object ;
5
- use objc2_exception:: { r#try, Exception } ;
5
+ use objc2_exception:: r#try;
6
6
7
7
// Comment copied from `objc2_exception`
8
8
@@ -21,6 +21,8 @@ use objc2_exception::{r#try, Exception};
21
21
/// undefined behaviour until `C-unwind` is stabilized, see [RFC-2945].
22
22
///
23
23
/// [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 ( ) ) ) )
26
28
}
Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ macro_rules! objc_try {
14
14
( $b: block) => {
15
15
$crate:: exception:: catch_exception( || $b) . map_err( |exception| {
16
16
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 ) )
19
19
} else {
20
- MessageError ( alloc :: format! ( "Uncaught exception {:?}" , & * * exception ) )
20
+ MessageError ( "Uncaught exception nil" . to_owned ( ) )
21
21
}
22
22
} )
23
23
} ;
You can’t perform that action at this time.
0 commit comments