CPF/CPF.Mac/Mac/Foundation/ObjCException.cs
2023-11-21 23:05:03 +08:00

34 lines
610 B
C#

using System;
namespace CPF.Mac.Foundation
{
public class ObjCException : Exception
{
private NSException native_exc;
public NSException NSException => native_exc;
public string Reason => native_exc.Reason;
public string Name => native_exc.Name;
public override string Message => $"{Name}: {Reason}";
public ObjCException()
{
native_exc = new NSException("default", string.Empty, null);
}
public ObjCException(NSException exc)
{
native_exc = exc;
}
[Preserve]
internal static void Throw(IntPtr handle)
{
throw new ObjCException(new NSException(handle));
}
}
}