- Base platform from base.git (ERP base: auth, core, config, message, workflow, plugin) - Created erp-diary module skeleton (lib.rs, dto.rs, error.rs, event.rs, state.rs) - Integrated erp-diary into workspace and erp-server - Added DiaryModule registration in main.rs - Added DiaryState FromRef in state.rs - Diary routes mounted (empty routes, ready for implementation) - Product design spec v1.2 preserved in docs/ - Implementation plan preserved in plans/ Cargo check: OK Cargo test: OK (78+ base tests passing)
56 lines
1.6 KiB
Rust
56 lines
1.6 KiB
Rust
use erp_core::error::AppError;
|
|
|
|
/// 插件模块错误类型
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum PluginError {
|
|
#[error("插件未找到: {0}")]
|
|
NotFound(String),
|
|
|
|
#[error("插件已存在: {0}")]
|
|
AlreadyExists(String),
|
|
|
|
#[error("无效的插件清单: {0}")]
|
|
InvalidManifest(String),
|
|
|
|
#[error("无效的插件状态: 期望 {expected}, 实际 {actual}")]
|
|
InvalidState { expected: String, actual: String },
|
|
|
|
#[error("插件执行错误: {0}")]
|
|
ExecutionError(String),
|
|
|
|
#[error("插件实例化错误: {0}")]
|
|
InstantiationError(String),
|
|
|
|
#[error("插件 Fuel 耗尽: {0}")]
|
|
FuelExhausted(String),
|
|
|
|
#[error("依赖未满足: {0}")]
|
|
DependencyNotSatisfied(String),
|
|
|
|
#[error("数据库错误: {0}")]
|
|
DatabaseError(String),
|
|
|
|
#[error("权限不足: {0}")]
|
|
PermissionDenied(String),
|
|
|
|
#[error("配置校验失败: {0}")]
|
|
ValidationError(String),
|
|
}
|
|
|
|
impl From<PluginError> for AppError {
|
|
fn from(err: PluginError) -> Self {
|
|
match &err {
|
|
PluginError::NotFound(_) => AppError::NotFound(err.to_string()),
|
|
PluginError::AlreadyExists(_) => AppError::Conflict(err.to_string()),
|
|
PluginError::InvalidManifest(_)
|
|
| PluginError::InvalidState { .. }
|
|
| PluginError::DependencyNotSatisfied(_)
|
|
| PluginError::ValidationError(_) => AppError::Validation(err.to_string()),
|
|
PluginError::PermissionDenied(_) => AppError::Forbidden(err.to_string()),
|
|
_ => AppError::Internal(err.to_string()),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub type PluginResult<T> = Result<T, PluginError>;
|