1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 12:25:04 +08:00

Reduce method complexity

This commit is contained in:
Dean Herbert 2019-07-30 17:52:06 +09:00
parent 6f91a21f00
commit 20b6114863

View File

@ -37,35 +37,13 @@ namespace osu.Game.Utils
if (exception != null)
{
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;
break;
case WebException we:
switch (we.Status)
{
// more statuses may need to be blocked as we come across them.
case WebExceptionStatus.Timeout:
return;
}
break;
}
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)));
@ -75,6 +53,34 @@ namespace osu.Game.Utils
};
}
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);