Made Config initialization errors more forgiving to noobs.
This commit is contained in:
@@ -26,6 +26,9 @@ end)
|
||||
|
||||
local failed, package = trygetpackage("[DebugOnlyTest]TestLuaMod")
|
||||
|
||||
print("packageFailed=", failed)
|
||||
print("package", package.Name)
|
||||
|
||||
local success, config = ConfigService.TryGetConfig(SettingBase.Single, package, "TestFloat")
|
||||
|
||||
print("config ", success, " ", config)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ModConfig>
|
||||
<Lua File="%ModDir%/Lua/init.lua" Target="Any" IsAutorun="true" />
|
||||
<Lua File="%ModDir%/Lua/init.lua" IsAutorun="true" />
|
||||
<Config File="%ModDir%/Settings.xml"/>
|
||||
</ModConfig>
|
||||
|
||||
@@ -325,6 +325,8 @@ public sealed partial class ConfigService : IConfigService
|
||||
{
|
||||
return FluentResults.Result.Ok();
|
||||
}
|
||||
|
||||
var result = new FluentResults.Result();
|
||||
|
||||
var taskBuilder = ImmutableArray.CreateBuilder<Task<ImmutableArray<IConfigInfo>>>();
|
||||
var toProcessErrors = new ConcurrentStack<IError>();
|
||||
@@ -362,7 +364,9 @@ public sealed partial class ConfigService : IConfigService
|
||||
{
|
||||
if (!_instanceFactory.TryGetValue(info.DataType, out var factory))
|
||||
{
|
||||
return FluentResults.Result.Fail($"{nameof(LoadConfigsAsync)}: Could not retrieve the instance factory for the data type of '{info.DataType}'!");
|
||||
result.WithError(
|
||||
$"{nameof(LoadConfigsAsync)}: Could not retrieve the instance factory for the data type of '{info.DataType}'!");
|
||||
continue;
|
||||
}
|
||||
if (_settingsInstances.ContainsKey((info.OwnerPackage, info.InternalName)))
|
||||
{
|
||||
@@ -383,13 +387,13 @@ public sealed partial class ConfigService : IConfigService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FluentResults.Result.Fail(
|
||||
result.WithError(
|
||||
$"{nameof(LoadConfigsAsync)}: Error while instancing setting for '{instanceFactoryInfo.configInfo.OwnerPackage}.{instanceFactoryInfo.configInfo.InternalName}': {e.Message}!");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
using var settingsLck = await _settingsByPackageLock.AcquireWriterLock(); // block to protect new bag instance creation
|
||||
var result = new FluentResults.Result();
|
||||
|
||||
while (toProcessInstanceQueue.TryDequeue(out var newInstanceData))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user