P2 平台通用服务: - manifest 扩展: settings/numbering/templates/trigger_events/importable/exportable 声明 - 插件配置 UI: PluginSettingsForm 自动表单 + 后端校验 + 详情抽屉 Settings 标签页 - 编号规则: Host API numbering-generate + PostgreSQL 序列 + manifest 绑定 - 触发事件: data_service create/update/delete 自动发布 DomainEvent - WIT 接口: 新增 numbering-generate/setting-get Host API P3 质量保障: - plugin_validator.rs: 安全扫描(WASM大小/实体数量/字段校验) + 复杂度评分 - 运行时监控指标: RuntimeMetrics (错误率/响应时间/Fuel/内存) - 性能基准: BenchmarkResult 阈值定义 - 上传时自动安全扫描 + /validate API 端点 P4 插件市场: - 数据库迁移: plugin_market_entries + plugin_market_reviews 表 - 前端 PluginMarket 页面: 分类浏览/搜索/详情/评分 - 路由注册: /plugins/market 测试: 269 全通过 (71 erp-plugin + 41 auth + 57 config + 34 core + 50 message + 16 workflow)
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>;
|