perf : 异常处理替换为YOO的异常类
This commit is contained in:
@@ -102,7 +102,7 @@ namespace YooAsset
|
||||
internal AssetInfo(string packageName, PackageAsset packageAsset, System.Type assetType)
|
||||
{
|
||||
if (packageAsset == null)
|
||||
throw new System.Exception("Should never get here !");
|
||||
throw new YooInternalException("Package asset can not be null.");
|
||||
|
||||
_providerGUID = string.Empty;
|
||||
_packageAsset = packageAsset;
|
||||
|
||||
+8
-8
@@ -115,9 +115,9 @@ namespace YooAsset
|
||||
|
||||
// 检测配置
|
||||
if (Manifest.EnableAddressable && Manifest.LocationToLower)
|
||||
throw new System.Exception("Addressable not support location to lower !");
|
||||
throw new YooManifestException("Addressable not support location to lower !");
|
||||
if (Manifest.EnableAddressable == false && Manifest.ReplaceAssetPathWithAddress)
|
||||
throw new System.Exception("Replace asset path with address need enable Addressable !");
|
||||
throw new YooManifestException("Replace asset path with address need enable Addressable !");
|
||||
|
||||
_steps = ESteps.PrepareAssetList;
|
||||
}
|
||||
@@ -216,12 +216,12 @@ namespace YooAsset
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Manifest = null;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = e.Message;
|
||||
Error = ex.Message;
|
||||
}
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
@@ -266,7 +266,7 @@ namespace YooAsset
|
||||
// 注意:我们不允许原始路径存在重名
|
||||
string assetPath = packageAsset.AssetPath;
|
||||
if (manifest.AssetDic.ContainsKey(assetPath))
|
||||
throw new System.Exception($"AssetPath have existed : {assetPath}");
|
||||
throw new YooManifestException($"AssetPath have existed : {assetPath}");
|
||||
else
|
||||
manifest.AssetDic.Add(assetPath, packageAsset);
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace YooAsset
|
||||
|
||||
// 添加原生路径的映射
|
||||
if (manifest.AssetPathMapping1.ContainsKey(location))
|
||||
throw new System.Exception($"Location have existed : {location}");
|
||||
throw new YooManifestException($"Location have existed : {location}");
|
||||
else
|
||||
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace YooAsset
|
||||
if (manifest.IncludeAssetGUID)
|
||||
{
|
||||
if (manifest.AssetPathMapping2.ContainsKey(packageAsset.AssetGUID))
|
||||
throw new System.Exception($"AssetGUID have existed : {packageAsset.AssetGUID}");
|
||||
throw new YooManifestException($"AssetGUID have existed : {packageAsset.AssetGUID}");
|
||||
else
|
||||
manifest.AssetPathMapping2.Add(packageAsset.AssetGUID, packageAsset.AssetPath);
|
||||
}
|
||||
@@ -310,7 +310,7 @@ namespace YooAsset
|
||||
if (string.IsNullOrEmpty(location) == false)
|
||||
{
|
||||
if (manifest.AssetPathMapping1.ContainsKey(location))
|
||||
throw new System.Exception($"Location have existed : {location}");
|
||||
throw new YooManifestException($"Location have existed : {location}");
|
||||
else
|
||||
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace YooAsset
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_fileName))
|
||||
throw new Exception("Should never get here !");
|
||||
throw new YooInternalException("File name can not be null or empty.");
|
||||
return _fileName;
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ namespace YooAsset
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_fileExtension))
|
||||
throw new Exception("Should never get here !");
|
||||
throw new YooInternalException("File extension can not be null or empty.");
|
||||
return _fileExtension;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid bundle id : {bundleID} Asset path : {packageAsset.AssetPath}");
|
||||
throw new YooManifestException($"Invalid bundle ID : {bundleID}. Valid range is 0 to {BundleList.Count - 1}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,11 +196,13 @@ namespace YooAsset
|
||||
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||
{
|
||||
var packageBundle = BundleList[bundleID];
|
||||
if (packageBundle == null)
|
||||
throw new YooInternalException();
|
||||
return packageBundle;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid bundle id : {bundleID}");
|
||||
throw new YooManifestException($"Invalid bundle ID : {bundleID}. Valid range is 0 to {BundleList.Count - 1}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace YooAsset
|
||||
private BundleInfo CreateBundleInfo(PackageBundle packageBundle)
|
||||
{
|
||||
if (packageBundle == null)
|
||||
throw new Exception("Should never get here !");
|
||||
throw new YooInternalException();
|
||||
|
||||
var fileSystem = GetBelongFileSystem(packageBundle);
|
||||
if (fileSystem != null)
|
||||
@@ -165,12 +165,12 @@ namespace YooAsset
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
throw new Exception($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
throw new YooFileSystemException($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
BundleInfo IBundleQuery.GetMainBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo == null || assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
throw new YooInternalException();
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.Asset);
|
||||
@@ -179,7 +179,7 @@ namespace YooAsset
|
||||
List<BundleInfo> IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo == null || assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
throw new YooInternalException();
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
List<PackageBundle> depends;
|
||||
|
||||
@@ -152,19 +152,19 @@ namespace YooAsset
|
||||
private void CheckInitializeParameters(InitializeParameters parameters)
|
||||
{
|
||||
if (_isInitialize)
|
||||
throw new Exception($"{nameof(ResourcePackage)} is initialized yet.");
|
||||
throw new YooPackageException(PackageName, $"Package '{PackageName}' is already initialized !");
|
||||
|
||||
if (parameters == null)
|
||||
throw new Exception($"{nameof(ResourcePackage)} create parameters is null.");
|
||||
throw new YooPackageException(PackageName, $"Initialize parameters cannot be null.");
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
if (parameters is EditorSimulateModeParameters)
|
||||
throw new Exception($"Editor simulate mode only support unity editor.");
|
||||
throw new YooPlatformNotSupportedException($"Editor simulate mode only support unity editor.");
|
||||
#endif
|
||||
|
||||
// 检测初始化参数
|
||||
if (parameters.BundleLoadingMaxConcurrency <= 0)
|
||||
throw new Exception($"{nameof(parameters.BundleLoadingMaxConcurrency)} value must be greater than zero.");
|
||||
throw new YooPackageException(PackageName, $"{nameof(parameters.BundleLoadingMaxConcurrency)} value must be greater than zero.");
|
||||
|
||||
// 鉴定运行模式
|
||||
if (parameters is EditorSimulateModeParameters)
|
||||
@@ -186,12 +186,12 @@ namespace YooAsset
|
||||
#if UNITY_WEBGL
|
||||
if (_playMode != EPlayMode.WebPlayMode)
|
||||
{
|
||||
throw new Exception($"{_playMode} can not support WebGL plateform !");
|
||||
throw new YooPlatformNotSupportedException($"{_playMode} can not support WebGL plateform !");
|
||||
}
|
||||
#else
|
||||
if (_playMode == EPlayMode.WebPlayMode)
|
||||
{
|
||||
throw new Exception($"{nameof(EPlayMode.WebPlayMode)} only support WebGL plateform !");
|
||||
throw new YooPlatformNotSupportedException($"{nameof(EPlayMode.WebPlayMode)} only support WebGL plateform !");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1158,14 +1158,14 @@ namespace YooAsset
|
||||
private void DebugCheckInitialize(bool checkActiveManifest = true)
|
||||
{
|
||||
if (_initializeStatus == EOperationStatus.None)
|
||||
throw new Exception("Package initialize not completed !");
|
||||
throw new YooPackageException(PackageName, "Package initialize not completed !");
|
||||
else if (_initializeStatus == EOperationStatus.Failed)
|
||||
throw new Exception($"Package initialize failed ! {_initializeError}");
|
||||
throw new YooPackageException(PackageName, $"Package initialize failed ! {_initializeError}");
|
||||
|
||||
if (checkActiveManifest)
|
||||
{
|
||||
if (_playModeImpl.ActiveManifest == null)
|
||||
throw new Exception("Can not found active package manifest !");
|
||||
throw new YooPackageException(PackageName, "Can not found active package manifest !");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1177,12 +1177,12 @@ namespace YooAsset
|
||||
|
||||
if (typeof(UnityEngine.Behaviour).IsAssignableFrom(type))
|
||||
{
|
||||
throw new Exception($"Load asset type is invalid : {type.FullName} !");
|
||||
throw new YooLoadException($"Load asset type is invalid : {type.FullName} !");
|
||||
}
|
||||
|
||||
if (typeof(UnityEngine.Object).IsAssignableFrom(type) == false)
|
||||
{
|
||||
throw new Exception($"Load asset type is invalid : {type.FullName} !");
|
||||
throw new YooLoadException($"Load asset type is invalid : {type.FullName} !");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user