From 4099cbb77aa3f0d6069eea51d47701ef94ebce03 Mon Sep 17 00:00:00 2001 From: SnipUndercover Date: Sat, 2 Nov 2024 20:12:38 +0100 Subject: [PATCH] Make `Deserialize` throw exceptions on failure --- Celeste.Mod.mm/Mod/Everest/ModAsset.cs | 28 ++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Celeste.Mod.mm/Mod/Everest/ModAsset.cs b/Celeste.Mod.mm/Mod/Everest/ModAsset.cs index 28e961f98..d0b57eb1f 100644 --- a/Celeste.Mod.mm/Mod/Everest/ModAsset.cs +++ b/Celeste.Mod.mm/Mod/Everest/ModAsset.cs @@ -88,21 +88,13 @@ protected ModAsset(ModContent source) { /// The asset in its deserialized (object) form. /// True if deserializing the asset succeeded, false otherwise. public bool TryDeserialize(out T result) { - if (Type == typeof(AssetTypeYaml)) { - try { - using (StreamReader reader = new StreamReader(Stream)) - result = YamlHelper.Deserializer.Deserialize(reader); - } catch { - result = default; - return false; - } + try { + result = Deserialize(); return true; + } catch { + result = default; + return false; } - - // TODO: Deserialize AssetTypeXml - - result = default; - return false; } /// @@ -111,8 +103,14 @@ public bool TryDeserialize(out T result) { /// The target type. /// The asset in its deserialized (object) form or default(T). public T Deserialize() { - TryDeserialize(out T result); - return result; + if (Type == typeof(AssetTypeYaml)) { + using StreamReader reader = new StreamReader(Stream); + return YamlHelper.Deserializer.Deserialize(reader); + } + + // TODO: Deserialize AssetTypeXml + + return default; } ///