diff --git a/GFramework.Game/Config/YamlConfigLoader.cs b/GFramework.Game/Config/YamlConfigLoader.cs index df99f1a6..5034f2cf 100644 --- a/GFramework.Game/Config/YamlConfigLoader.cs +++ b/GFramework.Game/Config/YamlConfigLoader.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using GFramework.Core.Abstractions.Events; using GFramework.Game.Abstractions.Config; using YamlDotNet.Serialization; @@ -299,6 +300,20 @@ public sealed class YamlConfigLoader : IConfigLoader Func keySelector, IEqualityComparer? comparer) { + Debug.Assert(!string.IsNullOrWhiteSpace(name), "Table registrations should always have a non-empty name."); + Debug.Assert(!string.IsNullOrWhiteSpace(relativePath), + "Table registrations should always have a non-empty relative path."); + + if (string.IsNullOrWhiteSpace(name)) + { + throw new ArgumentException(TableNameCannotBeNullOrWhiteSpaceMessage, nameof(name)); + } + + if (string.IsNullOrWhiteSpace(relativePath)) + { + throw new ArgumentException(RelativePathCannotBeNullOrWhiteSpaceMessage, nameof(relativePath)); + } + Name = name; RelativePath = relativePath; SchemaRelativePath = schemaRelativePath; @@ -365,10 +380,6 @@ public sealed class YamlConfigLoader : IConfigLoader { yaml = await File.ReadAllTextAsync(file, cancellationToken); } - catch (ConfigLoadException) - { - throw; - } catch (Exception exception) { throw ConfigLoadExceptionFactory.Create( @@ -399,10 +410,6 @@ public sealed class YamlConfigLoader : IConfigLoader values.Add(value); } - catch (ConfigLoadException) - { - throw; - } catch (Exception exception) { throw ConfigLoadExceptionFactory.Create( @@ -422,10 +429,6 @@ public sealed class YamlConfigLoader : IConfigLoader var table = new InMemoryConfigTable(values, _keySelector, _comparer); return new YamlTableLoadResult(Name, table, referencedTableNames, referenceUsages); } - catch (ConfigLoadException) - { - throw; - } catch (Exception exception) { throw ConfigLoadExceptionFactory.Create( diff --git a/GFramework.Game/Config/YamlConfigSchemaValidator.cs b/GFramework.Game/Config/YamlConfigSchemaValidator.cs index c2eee56f..a4af09bc 100644 --- a/GFramework.Game/Config/YamlConfigSchemaValidator.cs +++ b/GFramework.Game/Config/YamlConfigSchemaValidator.cs @@ -77,10 +77,6 @@ internal static class YamlConfigSchemaValidator return new YamlConfigSchema(schemaPath, rootNode, referencedTableNames.ToArray()); } - catch (ConfigLoadException) - { - throw; - } catch (JsonException exception) { throw ConfigLoadExceptionFactory.Create(