void AudioPlayer_UnobservedException(object sender, UnobservedTaskExceptionEventArgs e) { Debug.WriteLine("AudioPlayer UnobservedException {0}", e.Exception.Message); if (Debugger.IsAttached) Debugger.Break(); }
private static void InternalUnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs e) { var aggrException = e.Exception; var baseException = aggrException.GetBaseException(); var tplTask = (Task)sender; var contextObj = tplTask.AsyncState; var context = contextObj as ISchedulingContext; try { if (unobservedExceptionHandler != null) { unobservedExceptionHandler(context, baseException); } } finally { if (e.Observed) { logger.Info(ErrorCode.Runtime_Error_100311, "UnobservedExceptionsHandlerClass caught an UnobservedTaskException which was successfully observed and recovered from. BaseException = {0}. Exception = {1}", baseException.Message, LogFormatter.PrintException(aggrException)); } else { var errorStr = String.Format("UnobservedExceptionsHandlerClass Caught an UnobservedTaskException event sent by {0}. Exception = {1}", OrleansTaskExtentions.ToString((Task)sender), LogFormatter.PrintException(aggrException)); logger.Error(ErrorCode.Runtime_Error_100005, errorStr); logger.Error(ErrorCode.Runtime_Error_100006, "Exception remained UnObserved!!! The subsequent behavior depends on the ThrowUnobservedTaskExceptions setting in app config and .NET version."); } } }
protected override void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { logger.Error(e.Exception); e.SetObserved(); base.OnUnobservedTaskException(sender, e); }
private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { //var client = new Microsoft.ApplicationInsights.TelemetryClient(); //client.TrackException(e.Exception); _logger.Error(e.Exception); e.SetObserved(); }
private static void HandleTaskException(object sender, UnobservedTaskExceptionEventArgs e) { var exception = e.Exception; Console.WriteLine("Task Error: {0}", exception); Logger.Error("Task Error: " + exception.Message, exception); }
private static void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs) { var newExc = new Exception("TaskSchedulerOnUnobservedTaskException", unobservedTaskExceptionEventArgs.Exception); LogUnhandledException(newExc); }
static void HandleTaskSchedulerException(object sender, UnobservedTaskExceptionEventArgs e) { var exception = e != null ? (e.Exception ?? new Exception ("Unhandled Task exception (null Exception).")) : new Exception ("Unhandled Task exception (null UnobservedTaskExceptionEventArgs)."); HandleException (exception, fatal: false); }
void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { try { Exception ex = (Exception)e.Exception; string LogFile = Logger.LogError(ex); MessageBox.Show( "The application encountered a fatal error and must exit. This error has been logged and should be reported using the Error Report utility.\n\n" + "Error:\n" + ex.Message + "\n\nStack Trace:\n" + ex.StackTrace, "Fatal Error"); Process proc = new Process(); proc.EnableRaisingEvents = false; proc.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ErrorReport.exe"); proc.StartInfo.Arguments = LogFile; proc.Start(); } finally { System.Environment.Exit(1); } }
private void OnUnobservedTaskException(object sender, _THREADING.UnobservedTaskExceptionEventArgs e) { // prevent exception escalation e.SetObserved( ); _logger.LogError(String.Format("task Exception: '{0}'\r\nTrace:\r\n{1}", e.Exception.Message, e.Exception.StackTrace)); }
private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { var exception = e.Exception; var baseException = e.Exception.GetBaseException(); Logger.ErrorException("An unobserved task exception occured.", exception); e.SetObserved(); }
private void OnUnhandledExceptionRaised( object sender, UnobservedTaskExceptionEventArgs e ) { var handler = this.ExceptionCaught; if( handler.NotNullReference() ) handler(e.Exception); e.SetObserved(); }
private void TaskScheduler_UnobservedTaskException (object sender, UnobservedTaskExceptionEventArgs args) { args.Exception.Flatten(); var excArgs = new UnhandledExceptionsEventArgs(args.Exception.InnerExceptions, UnhandledExceptionSource.TaskScheduler); OnUnhandledException(excArgs); if (excArgs.Handled) args.SetObserved(); }
static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { e.SetObserved(); var exception = e.Exception.Flatten(); Logger.Error(exception); }
private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) { if (args?.Exception == null) { Logging.LogNullError(nameof(args) + " || " + nameof(args.Exception)); return; } Logging.LogFatalException(args.Exception); }
private static void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { Tracer.Get(typeof(Program)).Error(e.Exception.Flatten(), "Unexpected exception"); Console.WriteLine(e.Exception.Flatten().ToString()); Console.WriteLine("Press [Enter] to exit."); Console.ReadLine(); Process.GetCurrentProcess().Kill(); }
static void UnobservedException(object sender, UnobservedTaskExceptionEventArgs e) { if (Debugger.IsAttached) { // An unobserved exception has occurred; break into the debugger Debugger.Break(); } }
public static void handleUnObservedExceptions(object sender, UnobservedTaskExceptionEventArgs eventArgs) { eventArgs.SetObserved(); ((AggregateException)eventArgs.Exception).Handle(ex => { Console.WriteLine("Unobserved exception type: [{0}] Message[{1}] ", ex.GetType(), ex.Message); return true; }); }
private void OnTaskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { LogException(e.Exception); foreach (var exception in e.Exception.InnerExceptions) { LogException(exception); } }
void taskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { e.SetObserved(); e.Exception.Flatten().Handle(ex => { AppMessenger.Messenger.NotifyColleagues("ShowLog", ex.Message); return true; }); }
static void TaskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { foreach (var ex in e.Exception.InnerExceptions) { // NOTE: Should not observe the msg here, let the client of this library deal with that since there could be // other TPL Task created by the developers DefaultWatcher.Error(ex); } }
private static void Tasks_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { e.SetObserved(); var logger = ServiceLocator.Current.GetInstance<ILog>(); logger.Error( $"An unobserved task exception occures! Sender was {(sender != null ? sender.GetType().FullName : "(not set!)")}.", e.Exception); }
static void TaskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { foreach (var ex in e.Exception.InnerExceptions) { // NOTE: Should not observe the msg here, let the application developers deal with the error // because there could be other TPL Task created by the developers DefaultWatcher.Error(ex); } }
// Ensure unobserved task exceptions (unawaited async methods returning Task or Task<T>) are handled // Example: Call this method without 'await' // private async Task<string> TestStringTask() // { // throw new Exception("TestStringTaskException"); // } private void OnTaskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { if (e.Exception != null) { var isHandled = this.HandleException(e.Exception); if (isHandled) { e.SetObserved(); } } }
private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { if (handleUnobserved) { e.SetObserved(); Console.WriteLine("Unobserved exception logged and set to observed in TaskScheduler_UnobservedTaskException, Exception is: {0}", e.Exception); } else Console.WriteLine("Unobserved exception logged - process WILL BE KILLED because we are running .NET 4.0, Exception is: {0}", e.Exception); }
void OnUnobservedTaskException(object sender, System.Threading.Tasks.UnobservedTaskExceptionEventArgs e) { if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } else { Utilities.OnException(e.Exception); } }
static void HandleTaskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { if (e.Exception != null && e.Exception.InnerExceptions != null && e.Exception.InnerExceptions.Count > 0) { foreach (var exception in e.Exception.InnerExceptions) { Console.WriteLine("TaskScheduler Unobserved Exception"); Console.WriteLine(exception.Message); Console.WriteLine(exception.StackTrace); // Log.Error (exception, "TaskScheduler Unobserved Exception", true); } } }
/// <summary> /// 异步处理县城异常 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TaskScheduler_UnobservedTaskException(object sender, System.Threading.Tasks.UnobservedTaskExceptionEventArgs e) { try { ("异步处理县城异常:《" + e.Exception.ToString() + "》").WriteToLog(log4net.Core.Level.Error); e.SetObserved(); } catch (Exception ex) { ("不可恢复的异步处理县城异常:《" + ex.ToString() + "》").WriteToLog(log4net.Core.Level.Error); } }
private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs) { WindowsServerEventSource.Log.TaskSchedulerOnUnobservedTaskException(); var exp = new ExceptionTelemetry(unobservedTaskExceptionEventArgs.Exception) { HandledAt = ExceptionHandledAt.Unhandled, SeverityLevel = SeverityLevel.Critical, }; this.telemetryClient.TrackException(exp); }
private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs) { if (Debugger.IsAttached) Debug.WriteLine(unobservedTaskExceptionEventArgs.Exception.Message); else { MessageBox.Show(unobservedTaskExceptionEventArgs.Exception.Message); } unobservedTaskExceptionEventArgs.SetObserved(); }
private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs) { WindowsServerEventSource.Log.TaskSchedulerOnUnobservedTaskException(); var exp = new ExceptionTelemetry(unobservedTaskExceptionEventArgs.Exception) { SeverityLevel = SeverityLevel.Critical, }; // TODO: what if TrackException will throw another UnobservedTaskException? // Either put a comment here why it will never ever happen or include a protection logic this.telemetryClient.TrackException(exp); }
private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { // Imlementing this feature based on this request // https://support.hockeyapp.net/discussions/problems/58502-uwp-how-to-call-trackexception?mail_type=queue try { if (e.Exception != null) { ITelemetry crashTelemetry = CreateCrashTelemetry(e.Exception, ExceptionHandledAt.Unhandled); var client = ((HockeyClient)(HockeyClient.Current)); client.Track(crashTelemetry); client.Flush(); } } catch(Exception ex) { CoreEventSource.Log.LogError("An exeption occured in UnhandledExceptionTelemetryModule.TaskScheduler_UnobservedTaskException: " + ex); } }
private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { if (!e.Observed) { e.SetObserved(); Error error; lock (_syncRoot) { error = new Error(e.Exception) { HostName = _prototype.HostName, User = _prototype.User, }; error.ServerVariables.Add(_prototype.ServerVariables); error.QueryString.Add(_prototype.QueryString); error.Cookies.Add(_prototype.Cookies); error.Form.Add(_prototype.Form); } ErrorLog.GetDefault(null).Log(error); } }
static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { e.SetObserved(); }
//////////////////////////////////////////////////////////// // // Internal methods // // This is called by the TaskExceptionHolder finalizer. internal static void PublishUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs ueea) { UnobservedTaskException?.Invoke(sender, ueea); }
private static void TaskScheduler_UnobservedTaskException(object sender, System.Threading.Tasks.UnobservedTaskExceptionEventArgs e) { Log.Fatal(e.Exception, $"{nameof(TaskScheduler_UnobservedTaskException)}发生异常!"); }
/// <summary> /// Invoked when the task schedule sees an exception occur /// </summary> /// <param name="sender"></param> /// <param name="e">Details about the task exception.</param> private void TaskScheduler_UnobservedTaskException(object sender, System.Threading.Tasks.UnobservedTaskExceptionEventArgs e) { e.SetObserved(); Platform.Current.AppUnhandledException(e.Exception); }