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

View File

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