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

View File

@@ -87,11 +87,11 @@ namespace YooAsset
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
catch (Exception e)
catch (Exception ex)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Failed to load catalog file : {e.Message}";
Error = $"Failed to load catalog file : {ex.Message}";
}
}
}

View File

@@ -499,7 +499,7 @@ namespace YooAsset
{
if (_records.ContainsKey(bundle.BundleGUID))
{
throw new Exception("Should never get here !");
throw new YooInternalException();
}
string infoFilePath = GetBundleInfoFilePath(bundle);
@@ -521,9 +521,9 @@ namespace YooAsset
// 写入文件信息
WriteBundleInfoFile(infoFilePath, bundle.FileCRC, bundle.FileSize);
}
catch (Exception e)
catch (Exception ex)
{
YooLogger.Error($"Failed to write cache file ! {e.Message}");
YooLogger.Error($"Failed to write cache file ! {ex.Message}");
return false;
}

View File

@@ -37,9 +37,9 @@ namespace YooAsset
return false;
}
}
catch (Exception e)
catch (Exception ex)
{
YooLogger.Error($"Failed to delete cache file ! {e.Message}");
YooLogger.Error($"Failed to delete cache file ! {ex.Message}");
return false;
}
}

View File

@@ -33,9 +33,9 @@ namespace YooAsset
{
Directory.Delete(FileRootPath, true);
}
catch (System.Exception e)
catch (System.Exception ex)
{
YooLogger.Warning($"Failed to delete cache bundle folder : {e}");
YooLogger.Warning($"Failed to delete cache bundle folder : {ex}");
}
}
}

View File

@@ -320,11 +320,11 @@ namespace YooAsset
File.Move(recordFileElement.DataFilePath, filePath);
_steps = ESteps.LoadCacheRawBundle;
}
catch (Exception e)
catch (Exception ex)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Faild rename raw data file : {e.Message}";
Error = $"Faild rename raw data file : {ex.Message}";
}
}
else

View File

@@ -142,7 +142,7 @@ namespace YooAsset
PackageName = packageName;
if (string.IsNullOrEmpty(packageRoot))
throw new Exception($"{nameof(DefaultEditorFileSystem)} root directory is null or empty !");
throw new YooFileSystemException($"{nameof(DefaultEditorFileSystem)} package root is null or empty !");
_packageRoot = packageRoot;
}

View File

@@ -81,11 +81,11 @@ namespace YooAsset
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
catch (Exception e)
catch (Exception ex)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Failed to load catalog file : {e.Message}";
Error = $"Failed to load catalog file : {ex.Message}";
}
}
}