From 8c2c5f80bff4fa1a344378f090cad77e2f5c031e Mon Sep 17 00:00:00 2001 From: murdle Date: Fri, 2 May 2025 09:19:48 -0700 Subject: [PATCH] add error handling inside the resource class --- RobloxLegacy/Utilities/Resource.cs | 4 ++-- RobloxLegacy/VersionManager.cs | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/RobloxLegacy/Utilities/Resource.cs b/RobloxLegacy/Utilities/Resource.cs index 2ec2890..762cdc8 100644 --- a/RobloxLegacy/Utilities/Resource.cs +++ b/RobloxLegacy/Utilities/Resource.cs @@ -10,11 +10,11 @@ public class Resource(string name) return assembly.GetManifestResourceStream($"RobloxLegacy.Resources.{name}"); } - public byte[]? GetBytes() + public byte[] GetBytes() { using var stream = GetStream(); if (stream == null) - return null; + throw new Exception($"Failed to get {name} resource"); using var ms = new MemoryStream(); stream.CopyTo(ms); diff --git a/RobloxLegacy/VersionManager.cs b/RobloxLegacy/VersionManager.cs index 0ce7b72..6b9ec44 100644 --- a/RobloxLegacy/VersionManager.cs +++ b/RobloxLegacy/VersionManager.cs @@ -58,8 +58,6 @@ public class VersionManager : IDisposable private void WriteAppSettings() { var appSettings = new Resource("AppSettings.xml").GetBytes(); - if (appSettings == null) - throw new Exception("Failed to get AppSettings resource"); File.WriteAllBytesAsync(Path.Combine(GetVersionPath(_currentVersion), "AppSettings.xml"), appSettings); } @@ -73,8 +71,6 @@ public class VersionManager : IDisposable // now we can write the dll to the folder var dllContents = new Resource(DllName).GetBytes(); - if (dllContents == null) - throw new Exception("Failed to get dll resource"); File.WriteAllBytesAsync(Path.Combine(GetVersionPath(_currentVersion), DllName), dllContents); }