private static void ConvertToNsExceptionAndAbort(object e) { var nse = new NSException(".NET Exception", e.ToString(), null); var uncaught = NSGetUncaughtExceptionHandler(); var dele = (ReporterDelegate)Marshal.GetDelegateForFunctionPointer(uncaught, typeof(ReporterDelegate)); dele(nse.Handle); }
static void UncaughtExceptionHandler(IntPtr handle) { var exception = new NSException(handle); FA.FlurryAnalytics.LogError("3584", exception.Reason, exception); Console.WriteLine(@"Got an exception...{0} -- {1}", exception.Name, exception.Reason); }
// static void ConvertToNsExceptionAndAbort(object e) // { // var nse = new NSException(".NET Exception", e.ToString(), null); // var uncaught = NSGetUncaughtExceptionHandler(); // var dele = (ReporterDelegate)Marshal.GetDelegateForFunctionPointer(uncaught, typeof(ReporterDelegate)); // dele(nse.Handle); // } static void ConvertToNsExceptionAndAbort(object e) { var name = "Managed Xamarin.iOS .NET Exception"; var msg = e.ToString(); var ex = e as Exception; if(ex != null) name = string.Format("{0}: {1}", ex.GetType().FullName, ex.Message); name = name.Replace("%", "%%"); msg = msg.Replace("%", "%%"); var nse = new NSException(name, msg, null); var sel = new Selector("raise"); Messaging.void_objc_msgSend(nse.Handle, sel.Handle); }
private void ConvertToNsExceptionAndAbort(object e) { Console.WriteLine("ConvertToNSExceptionAndAbort"); var name = "Managed Xamarin.iOS .NET Exception"; var msg = e.ToString(); var ex = e as Exception; if (ex != null) { name = ex.GetType().FullName; if (ex.StackTrace != null) { msg = msg.Insert(msg.IndexOf('\n'), "Xamarin Exception Stack:"); Console.WriteLine("Inserted Xamarin Exception Stack Line!"); } else { Console.WriteLine("Could not find stacktrace!"); } } else { Console.WriteLine("Could not convert to exception!"); } Console.WriteLine("Name: " + name); Console.WriteLine("Message: " + msg); name = name.Replace("%", "%%"); msg = msg.Replace("%", "%%"); var nse = new NSException(name, msg, null); var sel = new Selector("raise"); global::Xamarin.ObjCRuntime.Messaging.void_objc_msgSend(nse.Handle, sel.Handle); }
private static void ConvertToNativeExceptionAndRaise(object e) { string name = "Managed Exception"; string reason = e.ToString(); Exception ex = e as Exception; if (ex != null) { string file = "Unknown file"; string line = "???"; try { if (!string.IsNullOrEmpty(reason)) { string buf = reason; buf = buf.Replace(ex.Message, ""); buf = buf.Replace(ex.GetType().FullName, ""); var pos = buf.IndexOf(" in "); var pos2 = buf.IndexOf(".cs", pos); file = buf.Substring(pos + 4, pos2 + 3 - (pos + 4)); file = Path.GetFileName(file); int i = pos2 + 4; string line2 = ""; char tmp = reason[i]; while ("0123456789".Contains(buf[i].ToString()) && i < buf.Length) line2 += buf[i++]; line = line2; } } catch { } name = string.Format("{0}: {1} - {2} line {3}", ex.GetType().FullName, ex.Message, file, line); } name = name.Replace("%", "%%"); reason = reason.Replace("%", "%%"); NSException nsex = new NSException(name, reason, null); Selector selector = new Selector("raise"); void_objc_msgSend(nsex.Handle, selector.Handle); }
private static void MyUncaughtExceptionHandler(IntPtr handle) { NSException exception = (NSException)Runtime.TryGetNSObject(handle); App.OnUnhandledException(new Exception(exception.Reason)); }
public MonoTouchException(NSException exc) : base() { native_exc = exc; }
public MonoTouchException() : base() { native_exc = new NSException ("default", String.Empty, null); }
public ObjCException(NSException exc) : base() { native_exc = exc; }
public ObjCException() : base() { native_exc = new NSException("default", String.Empty, null); }
public override void ReportError(string message, Exception exception) { var nsException = new NSException(exception.Source, exception.Message, null); YMMYandexMetrica.ReportError(message, nsException, null); }
public TrappedNativeException(NSException realException) : base($"A native exception was thrown: {realException.Description}") { NativeException = realException; }
public ObjCException(NSException exc, string stackTrace) { native_exc = exc; _stackTrace = stackTrace; }
protected virtual void RaiseNativeException(Exception ex) { string name = "Managed Exception"; string reason = "???"; NSException nsex = new NSException(name, reason, null); Selector selector = new Selector("raise"); void_objc_msgSend(nsex.Handle, selector.Handle); }
private static void MyUncaughtExceptionHandler(IntPtr exception) { var e = new NSException(exception); AppDelegate.HandleException(e.ToString()); }