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 IEcsProcess system: return AddSystem_Internal(system, settedAddParams);
case IEcsModule module: return AddModule_Internal(module, settedAddParams); case IEcsModule module: return AddModule_Internal(module, settedAddParams);
default: Throw.UndefinedException(); return this; default: Throw.ArgumentException("Unsupported type"); return this;
} }
} }
#endregion #endregion

View File

@ -28,7 +28,7 @@ namespace DCFApixels.DragonECS
Type targetInterface = processInterfaceType; Type targetInterface = processInterfaceType;
if (runnerType.IsAbstract || runnerType.IsInterface) if (runnerType.IsAbstract || runnerType.IsInterface)
{ {
Throw.UndefinedException(); Throw.Exception("The instance of a runner cannot be abstract.");
} }
Type GetRunnerBaseType(Type inType) 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 Exc(Type type) { return Exc(EcsTypeCodeManager.Get(type)); }
public Builder Inc(EcsTypeCode typeCode) public Builder Inc(EcsTypeCode typeCode)
{ {
if (_version != _builder._version) { Throw.UndefinedException(); } if (_version != _builder._version) { Throw.CantReuseBuilder(); }
_builder.Inc(typeCode); _builder.Inc(typeCode);
return this; return this;
} }
public Builder Exc(EcsTypeCode typeCode) public Builder Exc(EcsTypeCode typeCode)
{ {
if (_version != _builder._version) { Throw.UndefinedException(); } if (_version != _builder._version) { Throw.CantReuseBuilder(); }
_builder.Exc(typeCode); _builder.Exc(typeCode);
return this; return this;
} }
public Builder Combine(EcsStaticMask mask) public Builder Combine(EcsStaticMask mask)
{ {
if (_version != _builder._version) { Throw.UndefinedException(); } if (_version != _builder._version) { Throw.CantReuseBuilder(); }
_builder.Combine(mask); _builder.Combine(mask);
return this; return this;
} }
public Builder Except(EcsStaticMask mask) public Builder Except(EcsStaticMask mask)
{ {
if (_version != _builder._version) { Throw.UndefinedException(); } if (_version != _builder._version) { Throw.CantReuseBuilder(); }
_builder.Except(mask); _builder.Except(mask);
return this; return this;
} }
@ -305,7 +305,7 @@ namespace DCFApixels.DragonECS
#region Build/Cancel #region Build/Cancel
public EcsStaticMask Build() public EcsStaticMask Build()
{ {
if (_version != _builder._version) { Throw.UndefinedException(); } if (_version != _builder._version) { Throw.CantReuseBuilder(); }
lock (_lock) lock (_lock)
{ {
_buildersPool.Push(_builder); _buildersPool.Push(_builder);
@ -314,7 +314,7 @@ namespace DCFApixels.DragonECS
} }
public void Cancel() public void Cancel()
{ {
if (_version != _builder._version) { Throw.UndefinedException(); } if (_version != _builder._version) { Throw.CantReuseBuilder(); }
lock (_lock) lock (_lock)
{ {
_buildersPool.Push(_builder); _buildersPool.Push(_builder);

View File

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

View File

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

View File

@ -154,6 +154,14 @@ namespace DCFApixels.DragonECS.Internal
{ {
throw new Exception(); 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)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void Exception(string message) internal static void Exception(string message)
{ {