Xamarin - How to throw an unhandled exception to test AppDomain.CurrentDomain.UnhandledException method

112 Views Asked by At

Added the following to the AppDelegate FinishedLaunching but was wondering how to test? Trying to just throw an exception that either of this will catch

// Catch exceptions from all threads in the AppDomain.
AppDomain.CurrentDomain.UnhandledException += async (sender, args) => {
   await DialogService.ShowUnhandledExceptionMessage();
   HandleUnhandledException(args.ExceptionObject as Exception);
};

// Catch exceptions from each AppDomain that uses a task scheduler for async operations.
TaskScheduler.UnobservedTaskException += async (sender, args) => {
   await DialogService.ShowUnhandledExceptionMessage();
   HandleUnhandledException(args.Exception);
};
0

There are 0 best solutions below