public ErrorDetails(EnvironmentDetails environmentDetails, ExceptionHandlingDetails exceptionHandlingDetails, ExceptionDetails exceptionDetails, string faultingContextDetails, string programName) { EnvironmentDetails = environmentDetails; ExceptionHandlingDetails = exceptionHandlingDetails; ExceptionDetails = exceptionDetails; FaultingContextDetails = faultingContextDetails; ProgramName = programName; }
private void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { var result = MessageBox.Show( "Oh oh oh. Unhandled exception has occured. Would you like to continue program execution anyway?", "Unhandled exception has occured", MessageBoxButtons.YesNo); var continueExecution = result == DialogResult.Yes; var handlingDetails = new ExceptionHandlingDetails(true, continueExecution); SendErrorDetails("Exception occured on UI thread", e.Exception, handlingDetails); if (!continueExecution) { Environment.Exit(-1); } }
private static ErrorDetails CreateErrorDetails(string faultingContextDetails, Exception exception, ExceptionHandlingDetails exceptionHandlingDetails) => new ErrorDetails( GetEnvironmentDetails(), exceptionHandlingDetails, new ExceptionDetails(exception), faultingContextDetails, Assembly.GetExecutingAssembly().GetName().Name );
private void SendErrorDetails(string faultingContextDetails, Exception exception, ExceptionHandlingDetails exceptionHandlingDetails) { var details = CreateErrorDetails(faultingContextDetails, exception, exceptionHandlingDetails); var json = JsonConvert.SerializeObject(details, Formatting.Indented); var content = new StringContent(json, Encoding.UTF8, "application/json"); _httpClient.PostAsync("api/error-details", content).Wait(TimeSpan.FromSeconds(MaxResponseWaitTimeSec)); }
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { var handlingDetails = new ExceptionHandlingDetails(false, false); SendErrorDetails("Unhandled exception occured", e.ExceptionObject as Exception, handlingDetails); }