summaryrefslogtreecommitdiffstats
path: root/third_party/rust/objc/src/exception.rs
blob: 6fcfa7e87ad32df68c9f487d0a4ee6b9475e6d19 (plain)
1
2
3
4
5
6
7
8
9
10
11
use objc_exception;

use rc::StrongPtr;
use runtime::Object;

pub unsafe fn try<F, R>(closure: F) -> Result<R, StrongPtr>
        where F: FnOnce() -> R {
    objc_exception::try(closure).map_err(|exception| {
        StrongPtr::new(exception as *mut Object)
    })
}