mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Cover all non-APIAccess APIRequest calls with exception handling
This commit is contained in:
parent
5b5703544b
commit
0cd912fcd3
@ -392,8 +392,15 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
req.Failure += e => { LogForModel(set, $"Online retrieval failed for {beatmap} ({e.Message})"); };
|
||||
|
||||
// intentionally blocking to limit web request concurrency
|
||||
req.Perform(api);
|
||||
try
|
||||
{
|
||||
// intentionally blocking to limit web request concurrency
|
||||
req.Perform(api);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogForModel(set, $"Online retrieval failed for {beatmap} ({e.Message})");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,16 +86,7 @@ namespace osu.Game.Database
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
};
|
||||
|
||||
request.Failure += error =>
|
||||
{
|
||||
DownloadFailed?.Invoke(request);
|
||||
|
||||
if (error is OperationCanceledException) return;
|
||||
|
||||
notification.State = ProgressNotificationState.Cancelled;
|
||||
Logger.Error(error, $"{HumanisedModelName.Titleize()} download failed!");
|
||||
currentDownloads.Remove(request);
|
||||
};
|
||||
request.Failure += triggerFailure;
|
||||
|
||||
notification.CancelRequested += () =>
|
||||
{
|
||||
@ -108,11 +99,31 @@ namespace osu.Game.Database
|
||||
currentDownloads.Add(request);
|
||||
PostNotification?.Invoke(notification);
|
||||
|
||||
Task.Factory.StartNew(() => request.Perform(api), TaskCreationOptions.LongRunning);
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
request.Perform(api);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
triggerFailure(error);
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
|
||||
DownloadBegan?.Invoke(request);
|
||||
|
||||
return true;
|
||||
|
||||
void triggerFailure(Exception error)
|
||||
{
|
||||
DownloadFailed?.Invoke(request);
|
||||
|
||||
if (error is OperationCanceledException) return;
|
||||
|
||||
notification.State = ProgressNotificationState.Cancelled;
|
||||
Logger.Error(error, $"{HumanisedModelName.Titleize()} download failed!");
|
||||
currentDownloads.Remove(request);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAvailableLocally(TModel model) => CheckLocalAvailability(model, modelStore.ConsumableItems.Where(m => !m.DeletePending));
|
||||
|
@ -44,7 +44,17 @@ namespace osu.Game.Overlays.Changelog
|
||||
req.Failure += _ => complete = true;
|
||||
|
||||
// This is done on a separate thread to support cancellation below
|
||||
Task.Run(() => req.Perform(api));
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
req.Perform(api);
|
||||
}
|
||||
catch
|
||||
{
|
||||
complete = true;
|
||||
}
|
||||
});
|
||||
|
||||
while (!complete)
|
||||
{
|
||||
|
@ -170,6 +170,7 @@ namespace osu.Game.Overlays
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
var req = new GetChangelogRequest();
|
||||
|
||||
req.Success += res => Schedule(() =>
|
||||
{
|
||||
// remap streams to builds to ensure model equality
|
||||
@ -183,8 +184,22 @@ namespace osu.Game.Overlays
|
||||
|
||||
tcs.SetResult(true);
|
||||
});
|
||||
req.Failure += _ => initialFetchTask = null;
|
||||
req.Perform(API);
|
||||
|
||||
req.Failure += _ =>
|
||||
{
|
||||
initialFetchTask = null;
|
||||
tcs.SetResult(false);
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
req.Perform(API);
|
||||
}
|
||||
catch
|
||||
{
|
||||
initialFetchTask = null;
|
||||
tcs.SetResult(false);
|
||||
}
|
||||
|
||||
await tcs.Task;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user