use super::NSString;
use crate::core::Arc;
use crate::objc::NSObject;
mod name;
pub use name::NSExceptionName;
pub type NSUncaughtExceptionHandler = unsafe extern "C" fn(NSException);
#[inline]
#[allow(non_snake_case)]
pub fn NSGetUncaughtExceptionHandler() -> Option<NSUncaughtExceptionHandler> {
extern "C" {
fn NSGetUncaughtExceptionHandler() -> Option<NSUncaughtExceptionHandler>;
}
unsafe { NSGetUncaughtExceptionHandler() }
}
#[inline]
#[allow(non_snake_case)]
pub fn NSSetUncaughtExceptionHandler(handler: Option<NSUncaughtExceptionHandler>) {
extern "C" {
fn NSSetUncaughtExceptionHandler(handler: Option<NSUncaughtExceptionHandler>);
}
unsafe { NSSetUncaughtExceptionHandler(handler) }
}
objc_subclass! {
pub class NSException: NSObject<'static>;
}
impl NSException {
#[inline]
#[doc(alias = "objc_exception_throw")]
pub fn raise(&self) -> ! {
extern "C" {
fn objc_exception_throw(exception: &NSException) -> !;
}
unsafe { objc_exception_throw(self) }
}
}
impl NSException {
#[inline]
pub fn name(&self) -> Arc<NSExceptionName> {
unsafe { _msg_send_any![self, name] }
}
#[inline]
pub fn reason(&self) -> Option<Arc<NSString>> {
unsafe { _msg_send_any![self, reason] }
}
}
impl NSException {
}