// Returns true if the crash report can be sent, false if the sending is canceled. private bool OnSendingCrashReport(Exception originalException, RaygunCrashReport raygunCrashReport) { bool result = true; if (!_handlingRecursiveErrorSending) { EventHandler <RaygunSendingCrashReportEventArgs> handler = SendingCrashReport; if (handler != null) { RaygunSendingCrashReportEventArgs args = new RaygunSendingCrashReportEventArgs(originalException, raygunCrashReport); try { handler(this, args); } catch (Exception e) { // Catch and send exceptions that occur in the SendingCrashReport event handler. // Set the _handlingRecursiveErrorSending flag to prevent infinite errors. _handlingRecursiveErrorSending = true; Send(e); _handlingRecursiveErrorSending = false; } result = !args.Cancel; } } return(result); }
private async Task SendOrSaveCrashReportAsync(Exception originalException, RaygunCrashReport raygunCrashReport) { if (ValidateApiKey()) { bool canSend = OnSendingCrashReport(originalException, raygunCrashReport); if (canSend) { try { string payload = JsonConvert.SerializeObject(raygunCrashReport, HttpService.SERIALIZATION_SETTINGS); if (HttpService.IsInternetAvailable) { await SendCrashReportAsync(payload, true); SendStoredCrashReportsAsync(); } else { await SaveCrashReportAsync(payload); } } catch (Exception ex) { Debug.WriteLine($"Error Logging Exception to Raygun: {ex.Message}"); } } } }
private RaygunCrashReportBuilder() { _raygunCrashReport = new RaygunCrashReport(); }
public RaygunSendingCrashReportEventArgs(Exception originalException, RaygunCrashReport crashReport) { OriginalException = originalException; CrashReport = crashReport; }
/// <summary> /// Sends a RaygunCrashReport immediately to Raygun. /// </summary> /// <param name="raygunCrashReport">The RaygunCrashReport to send. This needs its OccurredOn property /// set to a valid DateTime and as much of the Details property as is available.</param> public void Send(RaygunCrashReport raygunCrashReport) { SendOrSaveCrashReportAsync(null, raygunCrashReport).Wait(3000); }
/// <summary> /// Asynchronously sends a RaygunCrashReport to Raygun. /// It is best to call this method within a try/catch block. /// If the application is crashing due to an unhandled exception, use the synchronous methods instead. /// </summary> /// <param name="raygunCrashReport">The RaygunCrashReport to send. This needs its OccurredOn property /// set to a valid DateTime and as much of the Details property as is available.</param> public async Task SendAsync(RaygunCrashReport raygunCrashReport) { await SendOrSaveCrashReportAsync(null, raygunCrashReport); }