add error handling inside the resource class
This commit is contained in:
		
							parent
							
								
									0d5dc9b3e5
								
							
						
					
					
						commit
						8c2c5f80bf
					
				@ -10,11 +10,11 @@ public class Resource(string name)
 | 
				
			|||||||
        return assembly.GetManifestResourceStream($"RobloxLegacy.Resources.{name}");
 | 
					        return assembly.GetManifestResourceStream($"RobloxLegacy.Resources.{name}");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public byte[]? GetBytes()
 | 
					    public byte[] GetBytes()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        using var stream = GetStream();
 | 
					        using var stream = GetStream();
 | 
				
			||||||
        if (stream == null)
 | 
					        if (stream == null)
 | 
				
			||||||
            return null;
 | 
					            throw new Exception($"Failed to get {name} resource");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        using var ms = new MemoryStream();
 | 
					        using var ms = new MemoryStream();
 | 
				
			||||||
        stream.CopyTo(ms);
 | 
					        stream.CopyTo(ms);
 | 
				
			||||||
 | 
				
			|||||||
@ -58,8 +58,6 @@ public class VersionManager : IDisposable
 | 
				
			|||||||
    private void WriteAppSettings()
 | 
					    private void WriteAppSettings()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        var appSettings = new Resource("AppSettings.xml").GetBytes();
 | 
					        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);
 | 
					        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
 | 
					        // now we can write the dll to the folder
 | 
				
			||||||
        var dllContents = new Resource(DllName).GetBytes();
 | 
					        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);
 | 
					        File.WriteAllBytesAsync(Path.Combine(GetVersionPath(_currentVersion), DllName), dllContents);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user