From 250c3a2fc97079bf5ea2c1bf6077e3295e1a1dac Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Mon, 24 Feb 2020 13:37:06 +0100 Subject: [PATCH] Loader: Unwrap FileFormatReader.Load exceptions --- .../FileFormatReaders/FileFormatReader.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs b/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs index e56747c..5ca0df8 100644 --- a/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs +++ b/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs @@ -60,10 +60,15 @@ namespace Il2CppInspector .Where(x => x.ImplementedInterfaces.Contains(typeof(IFileFormatReader)) && !x.IsGenericTypeDefinition); foreach (var type in types) { - if (type.GetMethod("Load", BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.Public, - null, new [] {typeof(Stream), typeof(EventHandler)}, null) - .Invoke(null, new object[] { stream, statusCallback }) is IFileFormatReader loaded) - return loaded; + try { + if (type.GetMethod("Load", BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.Public, + null, new[] {typeof(Stream), typeof(EventHandler)}, null) + .Invoke(null, new object[] {stream, statusCallback}) is IFileFormatReader loaded) + return loaded; + } + catch (TargetInvocationException ex) { + throw ex.InnerException; + } } return null; }