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
+5 -5
View File
@@ -117,7 +117,7 @@ namespace YooAsset
{
CheckException(packageName);
if (ContainsPackage(packageName))
throw new Exception($"Package {packageName} already existed !");
throw new YooPackageException(packageName, $"Package {packageName} already existed ! Cannot create duplicate packages.");
YooLogger.Log($"Create resource package : {packageName}");
ResourcePackage package = new ResourcePackage(packageName);
@@ -223,18 +223,18 @@ namespace YooAsset
private static void CheckException(string packageName)
{
if (_isInitialize == false)
throw new Exception($"{nameof(YooAssets)} not initialize !");
throw new YooInitializeException($"{nameof(YooAssets)} not initialized ! Please call {nameof(YooAssets.Initialize)} first.");
if (string.IsNullOrEmpty(packageName))
throw new Exception("Package name is null or empty !");
throw new YooInitializeException("Package name cannot be null or empty !");
}
private static void CheckException(ResourcePackage package)
{
if (_isInitialize == false)
throw new Exception($"{nameof(YooAssets)} not initialize !");
throw new YooInitializeException($"{nameof(YooAssets)} not initialized ! Please call {nameof(YooAssets.Initialize)} first.");
if (package == null)
throw new Exception("Package instance is null !");
throw new YooInitializeException("Package instance cannot be null !");
}
#region 系统参数