Skip to main content

zerolaunch_plugin_api/host/
error.rs

1use crate::platform::capabilities::PlatformCapability;
2
3/// HostApi 统一错误类型。
4/// 涵盖能力查询失败、注册失败、各服务操作失败等场景。
5#[derive(Debug, thiserror::Error)]
6pub enum HostApiError {
7    /// 当前平台不支持请求的能力
8    #[error("平台不支持该能力: {0:?}")]
9    UnsupportedCapability(PlatformCapability),
10
11    /// 插件未注册或 plugin_id 不存在
12    #[error("插件未注册: {0}")]
13    PluginNotRegistered(String),
14
15    /// 图标提取失败
16    #[error("图标提取失败 (请求: {request}): {reason}")]
17    IconExtractionFailed { request: String, reason: String },
18
19    /// Shell 操作失败
20    #[error("Shell 操作失败 (目标: {target}): {reason}")]
21    ShellOperationFailed { target: String, reason: String },
22
23    /// 窗口操作失败
24    #[error("窗口操作失败: {detail}")]
25    WindowOperationFailed { detail: String },
26
27    /// 通用执行失败
28    #[error("{service} 执行失败: {reason}")]
29    ExecutionFailed { service: String, reason: String },
30
31    /// 路径解析失败
32    #[error("路径解析失败 ({path}): {reason}")]
33    PathResolutionFailed { path: String, reason: String },
34
35    /// 应用枚举失败
36    #[error("应用枚举失败: {reason}")]
37    AppEnumerationFailed { reason: String },
38
39    /// 应用启动失败
40    #[error("应用启动失败 (app_id: {app_id}): {reason}")]
41    AppLaunchFailed { app_id: String, reason: String },
42
43    /// Lnk 快捷方式解析失败
44    #[error("Lnk 解析失败 ({path}): {reason}")]
45    LnkResolutionFailed { path: String, reason: String },
46
47    /// 参数解析失败
48    #[error("参数解析失败: {reason}")]
49    ParameterResolutionFailed { reason: String },
50
51    /// 自启动操作失败
52    #[error("自启动操作失败: {reason}")]
53    AutoStartFailed { reason: String },
54
55    /// 存储操作失败
56    #[error("存储操作失败 ({file}): {reason}")]
57    StorageOperationFailed { file: String, reason: String },
58
59    /// 资源未找到
60    #[error("资源未找到: {id}")]
61    ResourceNotFound { id: String },
62
63    /// 资源路径包含路径遍历字符 (如 "..")
64    #[error("路径遍历被拒绝: {path}")]
65    PathTraversalRejected { path: String },
66}