From 762e3119401fbee25ec18fee2ff220d9b12d48e8 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 11 Feb 2026 21:44:05 +0800 Subject: Add sheet system and reorganize workspace - Add new "sheet" crate to workspace - Rename "systems/asset" to "systems/_asset" - Reorder workspace members and dependencies for clarity - Update constants with new paths for auth and rules - Add conditional compilation for system module --- systems/_asset/src/error.rs | 106 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 systems/_asset/src/error.rs (limited to 'systems/_asset/src/error.rs') diff --git a/systems/_asset/src/error.rs b/systems/_asset/src/error.rs new file mode 100644 index 0000000..5dc529f --- /dev/null +++ b/systems/_asset/src/error.rs @@ -0,0 +1,106 @@ +use std::path::PathBuf; + +#[derive(Debug, thiserror::Error)] +pub enum DataReadError { + #[error("IO error: {0}")] + IoError(#[from] std::io::Error), + + #[error("Parse error: {0}")] + ParseError(String), +} + +#[derive(Debug, thiserror::Error)] +pub enum DataWriteError { + #[error("IO error: {0}")] + IoError(#[from] std::io::Error), +} + +#[derive(Debug, thiserror::Error)] +pub enum DataApplyError { + #[error("IO error: {0}")] + IoError(#[from] std::io::Error), + + #[error("Asset file not found: {0}")] + AssetFileNotFound(PathBuf), + + #[error("Pre-check failed: {0}")] + PrecheckFailed(#[from] PrecheckFailed), +} + +#[derive(Debug, thiserror::Error)] +pub enum PrecheckFailed { + /// Lock file does not exist + /// Means trying to apply a modification that cannot be applied + #[error("Lock not found")] + LockNotFound, + + /// Asset file does not exist + /// Apply phase will fail due to this condition + #[error("Asset not found")] + AssetNotFound, + + // Note: !writed is allowed, + // but writed without a TEMP_FILE is not allowed + /// Handle produced a write + /// but the temporary file does not exist, indicating an abnormal write operation + #[error("Temp not found")] + WritedButTempNotFound, + + /// Asset path is invalid + /// This is not an issue that should arise from normal Handle creation flow + #[error("Asset path invalid")] + AssetPathInvalid, + + /// Temporary file cannot be moved + #[error("Temp file not moveable")] + TempNotMoveable, + + /// Asset file cannot be moved + #[error("Asset file not writable")] + AssetNotWritable, + + /// Handle is processing a cross-directory operation + /// This is not atomic + #[error("Handle is cross-directory")] + HandleIsCrossDirectory, + + /// Asset file has no parent directory + /// This is not a valid path for file operations + #[error("Asset file has no parent directory")] + HandleFileIsNoParent, + + /// A handle with the same path already exists + /// This operation will cause a conflict + #[error("Handle with same path exists")] + HasSamePath, + + #[error("Lock on lock file")] + LockOnLockFile, + + #[error("Temp file for temp file")] + TempForTempFile, + + #[error("Asset path cannot be formatted")] + FormatPathFailed, +} + +#[derive(Debug, thiserror::Error)] +pub enum HandleLockError { + #[error("Parse path failed")] + ParsePathFailed, + + #[error("Asset file not found")] + AssetFileNotFound(PathBuf), + + #[error("Read file name failed")] + ReadFileNameFailed, + + #[error("Asset locked")] + AssetLocked, + + #[error("IO error: {0}")] + IoError(#[from] std::io::Error), + + #[error("Pre-check failed: {0}")] + PrecheckFailed(#[from] PrecheckFailed), +} -- cgit