Merge pull request #5528 from peppy/no-sentry-timeouts

Don't forward timeout exceptions to sentry
This commit is contained in:
Dan Balasescu 2019-07-30 18:59:49 +09:00 committed by GitHub
commit 1d3d8e192c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 11 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using osu.Framework.Logging;
using SharpRaven;
@ -36,22 +37,13 @@ public RavenLogger(OsuGame game)
if (exception != null)
{
if (exception is IOException ioe)
{
// disk full exceptions, see https://stackoverflow.com/a/9294382
const int hr_error_handle_disk_full = unchecked((int)0x80070027);
const int hr_error_disk_full = unchecked((int)0x80070070);
if (ioe.HResult == hr_error_handle_disk_full || ioe.HResult == hr_error_disk_full)
return;
}
if (!shouldSubmitException(exception))
return;
// since we let unhandled exceptions go ignored at times, we want to ensure they don't get submitted on subsequent reports.
if (lastException != null &&
lastException.Message == exception.Message && exception.StackTrace.StartsWith(lastException.StackTrace))
{
return;
}
lastException = exception;
queuePendingTask(raven.CaptureAsync(new SentryEvent(exception) { Message = entry.Message }));
@ -61,6 +53,34 @@ public RavenLogger(OsuGame game)
};
}
private bool shouldSubmitException(Exception exception)
{
switch (exception)
{
case IOException ioe:
// disk full exceptions, see https://stackoverflow.com/a/9294382
const int hr_error_handle_disk_full = unchecked((int)0x80070027);
const int hr_error_disk_full = unchecked((int)0x80070070);
if (ioe.HResult == hr_error_handle_disk_full || ioe.HResult == hr_error_disk_full)
return false;
break;
case WebException we:
switch (we.Status)
{
// more statuses may need to be blocked as we come across them.
case WebExceptionStatus.Timeout:
return false;
}
break;
}
return true;
}
private void queuePendingTask(Task<string> task)
{
lock (tasks) tasks.Add(task);