perf : 异常处理替换为YOO的异常类

This commit is contained in:
何冠峰
2025-12-05 15:45:04 +08:00
parent 5da8c6baf8
commit e5d0a856a5
27 changed files with 243 additions and 74 deletions
@@ -265,18 +265,18 @@ namespace YooAsset
public void ReleaseHandle(HandleBase handle)
{
if (RefCount <= 0)
throw new System.Exception("Should never get here !");
throw new YooInternalException($"Attempting to release handle when RefCount is already zero. Asset : {MainAssetInfo.AssetPath}");
if (_resManager.UseWeakReferenceHandle)
{
// TODO 高危风险:如果移除弱引用失败,会导致资源永远无法释放。
if (RemoveWeakReference(handle) == false)
throw new System.Exception("Should never get here !");
throw new YooInternalException($"Handle not found in weak reference list. Asset: {MainAssetInfo.AssetPath}");
}
else
{
if (_handles.Remove(handle) == false)
throw new System.Exception("Should never get here !");
throw new YooInternalException($"Handle not found in cache list. Asset: {MainAssetInfo.AssetPath}");
}
// 引用计数减少
@@ -385,7 +385,7 @@ namespace YooAsset
}
if (status.TotalBytes == 0)
throw new System.Exception("Should never get here !");
throw new YooInternalException("Download total size can not be zero.");
status.IsDone = status.DownloadedBytes == status.TotalBytes;
status.Progress = (float)status.DownloadedBytes / status.TotalBytes;