配置: - rustfmt.toml: 固化 max_width=100 / 4 空格缩进,cargo fmt 全量格式化 - Cargo.toml: 配置 [lints.rust] 与 [lints.clippy] 渐进式规则 - .github/workflows/ci.yml: Rust(fmt+clippy+test) + 前端(eslint+tsc+test) 双平台 CI - Makefile: 新增 check/fmt/fix 目标,clippy 对齐 --all-targets --all-features - web: eslint flat config + prettier 配置 + package.json 脚本与依赖 - src/main.rs: loop→while 修复 clippy::never_loop 对抗性审查发现并修复: - eslint 缺 caughtErrorsIgnorePattern 导致 catch(_) 误报为 error - 前端 lint 未接入 CI,现已补上 Lint 步骤 - Makefile 与 CI 的 clippy flags 不一致,已对齐
49 lines
1.3 KiB
Rust
49 lines
1.3 KiB
Rust
use crate::storage::StorageError;
|
|
|
|
/// 任务错误类型
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum TaskError {
|
|
#[error("Task session not found: {0}")]
|
|
SessionNotFound(String),
|
|
|
|
#[error("Invalid parent session")]
|
|
InvalidParentSession,
|
|
|
|
#[error("Failed to create subagent: {0}")]
|
|
AgentCreationFailed(String),
|
|
|
|
#[error("Execution failed: {0}")]
|
|
ExecutionFailed(String),
|
|
|
|
#[error("Task execution timed out")]
|
|
Timeout,
|
|
|
|
#[error("Repository error: {0}")]
|
|
RepositoryError(#[from] StorageError),
|
|
|
|
#[error("Serialization error: {0}")]
|
|
SerializationError(#[from] serde_json::Error),
|
|
|
|
#[error("Missing required context: {0}")]
|
|
MissingContext(String),
|
|
|
|
#[error("Invalid arguments: {0}")]
|
|
InvalidArguments(String),
|
|
}
|
|
|
|
impl TaskError {
|
|
pub fn as_status(&self) -> &'static str {
|
|
match self {
|
|
Self::Timeout => "timeout",
|
|
Self::SessionNotFound(_) => "failed",
|
|
Self::InvalidParentSession => "failed",
|
|
Self::AgentCreationFailed(_) => "failed",
|
|
Self::ExecutionFailed(_) => "failed",
|
|
Self::RepositoryError(_) => "failed",
|
|
Self::SerializationError(_) => "failed",
|
|
Self::MissingContext(_) => "failed",
|
|
Self::InvalidArguments(_) => "failed",
|
|
}
|
|
}
|
|
}
|