1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 10:03:05 +08:00

Unify error handling

This commit is contained in:
smoogipoo 2020-02-10 17:25:11 +09:00
parent 668f36d7f3
commit 0ab3982494
2 changed files with 19 additions and 12 deletions

View File

@ -36,8 +36,9 @@ namespace osu.Game.Beatmaps
using (var stream = new LineBufferedReader(store.GetStream(getPathForFile(BeatmapInfo.Path)))) using (var stream = new LineBufferedReader(store.GetStream(getPathForFile(BeatmapInfo.Path))))
return Decoder.GetDecoder<Beatmap>(stream).Decode(stream); return Decoder.GetDecoder<Beatmap>(stream).Decode(stream);
} }
catch catch (Exception e)
{ {
Logger.Error(e, "Beatmap failed to load");
return null; return null;
} }
} }
@ -59,8 +60,9 @@ namespace osu.Game.Beatmaps
{ {
return textureStore.Get(getPathForFile(Metadata.BackgroundFile)); return textureStore.Get(getPathForFile(Metadata.BackgroundFile));
} }
catch catch (Exception e)
{ {
Logger.Error(e, "Background failed to load");
return null; return null;
} }
} }
@ -74,8 +76,9 @@ namespace osu.Game.Beatmaps
{ {
return new VideoSprite(textureStore.GetStream(getPathForFile(Metadata.VideoFile))); return new VideoSprite(textureStore.GetStream(getPathForFile(Metadata.VideoFile)));
} }
catch catch (Exception e)
{ {
Logger.Error(e, "Video failed to load");
return null; return null;
} }
} }
@ -86,8 +89,9 @@ namespace osu.Game.Beatmaps
{ {
return (trackStore ??= AudioManager.GetTrackStore(store)).Get(getPathForFile(Metadata.AudioFile)); return (trackStore ??= AudioManager.GetTrackStore(store)).Get(getPathForFile(Metadata.AudioFile));
} }
catch catch (Exception e)
{ {
Logger.Error(e, "Track failed to load");
return null; return null;
} }
} }
@ -115,8 +119,9 @@ namespace osu.Game.Beatmaps
var trackData = store.GetStream(getPathForFile(Metadata.AudioFile)); var trackData = store.GetStream(getPathForFile(Metadata.AudioFile));
return trackData == null ? null : new Waveform(trackData); return trackData == null ? null : new Waveform(trackData);
} }
catch catch (Exception e)
{ {
Logger.Error(e, "Waveform failed to load");
return null; return null;
} }
} }

View File

@ -184,14 +184,16 @@ namespace osu.Game.Beatmaps
} }
catch (AggregateException ae) catch (AggregateException ae)
{ {
foreach (var e in ae.InnerExceptions) // This is the exception that is generally expected here, which occurs via natural cancellation of the asynchronous load
{ if (ae.InnerExceptions.FirstOrDefault() is TaskCanceledException)
if (e is TaskCanceledException) return null;
continue;
Logger.Log(e.Message);
}
Logger.Error(ae, "Beatmap failed to load");
return null;
}
catch (Exception e)
{
Logger.Error(e, "Beatmap failed to load");
return null; return null;
} }
} }