Browse Source

Improved error handling with new features

pull/53/head
Anairkoen Schno 3 years ago
parent
commit
a88ca4bb18
Signed by: DaNike GPG Key ID: BEFB74D5F3FC4387
2 changed files with 20 additions and 6 deletions
  1. +8
    -2
      IPA.Loader/Loader/Features/Feature.cs
  2. +12
    -4
      IPA.Loader/Loader/PluginLoader.cs

+ 8
- 2
IPA.Loader/Loader/Features/Feature.cs View File

@ -106,6 +106,10 @@ namespace IPA.Loader.Features
if (definingPlugin != declarer)
return false;
}
else
{
featureDelcarers.Add(name, definingPlugin);
}
featureTypes.Add(name, type);
return true;
@ -144,11 +148,13 @@ namespace IPA.Loader.Features
// returns whether or not Initialize returned true, feature is always set when the thing exists
public bool TryCreate(out Feature feature)
{
feature = null;
if (type == null)
{
if (!featureTypes.TryGetValue(Name, out type))
{
feature = new EmptyFeature() { InvalidMessage = "No such feature type found", FeatureName = Name };
return false;
}
}
bool result;
@ -162,7 +168,7 @@ namespace IPA.Loader.Features
catch (Exception e)
{
result = false;
feature = new EmptyFeature() { InvalidMessage = e.ToString() };
feature = new EmptyFeature() { InvalidMessage = e.ToString(), FeatureName = Name };
}
return result;
}


+ 12
- 4
IPA.Loader/Loader/PluginLoader.cs View File

@ -878,11 +878,19 @@ namespace IPA.Loader
var loaded = new HashSet<PluginMetadata>();
foreach (var meta in PluginsMetadata)
{
var exec = InitPlugin(meta, loaded);
if (exec != null)
try
{
var exec = InitPlugin(meta, loaded);
if (exec != null)
{
list.Add(exec);
loaded.Add(meta);
}
}
catch (Exception e)
{
list.Add(exec);
loaded.Add(meta);
Logger.log.Critical($"Uncaught exception while loading pluign {meta.Name}:");
Logger.log.Critical(e);
}
}


Loading…
Cancel
Save