Simplify casting of ReflectionTypeLoadException

This commit is contained in:
Aireil 2021-02-15 13:26:57 +01:00
parent 34a1eb0b9c
commit 2e4f11b2ad
2 changed files with 2 additions and 4 deletions

View file

@ -104,8 +104,7 @@ namespace Dalamud.Plugin
} }
catch (Exception ex) { catch (Exception ex) {
Log.Error(ex, $"Plugin load for {dllFile.FullName} failed."); Log.Error(ex, $"Plugin load for {dllFile.FullName} failed.");
if (ex is ReflectionTypeLoadException) { if (ex is ReflectionTypeLoadException typeLoadException) {
var typeLoadException = ex as ReflectionTypeLoadException;
foreach (var exception in typeLoadException.LoaderExceptions) { foreach (var exception in typeLoadException.LoaderExceptions) {
Log.Error(exception, "LoaderException:"); Log.Error(exception, "LoaderException:");
} }

View file

@ -152,8 +152,7 @@ namespace Dalamud.Plugin
} }
catch (Exception ex) { catch (Exception ex) {
Log.Error(ex, "Plugin download failed hard."); Log.Error(ex, "Plugin download failed hard.");
if (ex is ReflectionTypeLoadException) { if (ex is ReflectionTypeLoadException typeLoadException) {
var typeLoadException = ex as ReflectionTypeLoadException;
foreach (var exception in typeLoadException.LoaderExceptions) { foreach (var exception in typeLoadException.LoaderExceptions) {
Log.Error(exception, "LoaderException:"); Log.Error(exception, "LoaderException:");
} }