update exception messages

This commit is contained in:
Mikhail 2024-11-06 19:55:33 +08:00
parent 51b623e2c5
commit 08a19489e8
6 changed files with 19 additions and 11 deletions

View File

@ -214,7 +214,7 @@ namespace DCFApixels.DragonECS
{
case IEcsProcess system: return AddSystem_Internal(system, settedAddParams);
case IEcsModule module: return AddModule_Internal(module, settedAddParams);
default: Throw.UndefinedException(); return this;
default: Throw.ArgumentException("Unsupported type"); return this;
}
}
#endregion

View File

@ -28,7 +28,7 @@ namespace DCFApixels.DragonECS
Type targetInterface = processInterfaceType;
if (runnerType.IsAbstract || runnerType.IsInterface)
{
Throw.UndefinedException();
Throw.Exception("The instance of a runner cannot be abstract.");
}
Type GetRunnerBaseType(Type inType)
{

View File

@ -278,25 +278,25 @@ namespace DCFApixels.DragonECS
public Builder Exc(Type type) { return Exc(EcsTypeCodeManager.Get(type)); }
public Builder Inc(EcsTypeCode typeCode)
{
if (_version != _builder._version) { Throw.UndefinedException(); }
if (_version != _builder._version) { Throw.CantReuseBuilder(); }
_builder.Inc(typeCode);
return this;
}
public Builder Exc(EcsTypeCode typeCode)
{
if (_version != _builder._version) { Throw.UndefinedException(); }
if (_version != _builder._version) { Throw.CantReuseBuilder(); }
_builder.Exc(typeCode);
return this;
}
public Builder Combine(EcsStaticMask mask)
{
if (_version != _builder._version) { Throw.UndefinedException(); }
if (_version != _builder._version) { Throw.CantReuseBuilder(); }
_builder.Combine(mask);
return this;
}
public Builder Except(EcsStaticMask mask)
{
if (_version != _builder._version) { Throw.UndefinedException(); }
if (_version != _builder._version) { Throw.CantReuseBuilder(); }
_builder.Except(mask);
return this;
}
@ -305,7 +305,7 @@ namespace DCFApixels.DragonECS
#region Build/Cancel
public EcsStaticMask Build()
{
if (_version != _builder._version) { Throw.UndefinedException(); }
if (_version != _builder._version) { Throw.CantReuseBuilder(); }
lock (_lock)
{
_buildersPool.Push(_builder);
@ -314,7 +314,7 @@ namespace DCFApixels.DragonECS
}
public void Cancel()
{
if (_version != _builder._version) { Throw.UndefinedException(); }
if (_version != _builder._version) { Throw.CantReuseBuilder(); }
lock (_lock)
{
_buildersPool.Push(_builder);

View File

@ -209,7 +209,7 @@ namespace DCFApixels.DragonECS
if (oldPool != _nullPool)
{
Throw.UndefinedException();
Throw.Exception("Attempt to initialize a pool with the indetifier of an already existing pool.");
}
_pools[componentTypeID] = newPool;
@ -390,7 +390,7 @@ namespace DCFApixels.DragonECS
if (_lockedPoolCount < 0)
{
_lockedPoolCount = 0;
Throw.UndefinedException();
Throw.OpeningClosingMethodsBalanceError();
}
_pools[ComponentTypeID].OnLockedChanged_Debug(false);
}

View File

@ -93,7 +93,7 @@ namespace DCFApixels.DragonECS
public static ref T GetForWorldUnchecked(int worldID)
{// ts
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_mapping[worldID] <= 0) { Throw.UndefinedException(); }
if (_mapping[worldID] <= 0) { Throw.ArgumentOutOfRange(); }
#endif
return ref _items[_mapping[worldID]];
}

View File

@ -154,6 +154,14 @@ namespace DCFApixels.DragonECS.Internal
{
throw new Exception();
}
internal static void OpeningClosingMethodsBalanceError()
{
throw new InvalidOperationException("Error of opening - closing methods. Closing method was called more often than opening method.");
}
internal static void CantReuseBuilder()
{
throw new InvalidOperationException("Builder has already worked out, use the new builder to build again.");
}
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void Exception(string message)
{