Skip to main content

victauri_plugin/
error.rs

1//! Typed error enums for the `victauri-plugin` crate.
2
3/// Errors that can occur when building the Victauri plugin via [`crate::VictauriBuilder`].
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum BuilderError {
7    #[error("invalid port {port}: {reason}")]
8    InvalidPort { port: u16, reason: String },
9
10    #[error("invalid event capacity {capacity}: {reason}")]
11    InvalidEventCapacity { capacity: usize, reason: String },
12
13    #[error("invalid recorder capacity {capacity}: {reason}")]
14    InvalidRecorderCapacity { capacity: usize, reason: String },
15
16    #[error("invalid eval timeout {timeout_secs}s: {reason}")]
17    InvalidEvalTimeout { timeout_secs: u64, reason: String },
18}
19
20/// Errors that can occur during MCP server operation, tool execution, or webview interaction.
21#[derive(Debug, thiserror::Error)]
22#[non_exhaustive]
23pub enum PluginError {
24    #[error("eval timed out after {timeout_secs}s")]
25    EvalTimeout { timeout_secs: u64 },
26
27    #[error("eval failed: {message}")]
28    EvalFailed { message: String },
29
30    #[error("too many concurrent eval requests (limit: {limit})")]
31    EvalConcurrencyExceeded { limit: usize },
32
33    #[error("bridge error: {message}")]
34    BridgeError { message: String },
35
36    #[error("screenshot failed: {message}")]
37    ScreenshotFailed { message: String },
38
39    #[error("authentication failed: {message}")]
40    AuthenticationFailed { message: String },
41
42    #[error("rate limit exceeded")]
43    RateLimitExceeded,
44
45    #[error("tool '{tool_name}' is disabled by privacy configuration")]
46    ToolDisabled { tool_name: String },
47
48    #[error("command '{command}' is blocked by privacy configuration")]
49    CommandBlocked { command: String },
50
51    #[error("window not found: {label}")]
52    WindowNotFound { label: String },
53
54    #[error("MCP server failed to start: {message}")]
55    ServerStartFailed { message: String },
56
57    #[error("port {port} is already in use")]
58    PortInUse { port: u16 },
59
60    #[error("serialization error: {0}")]
61    Serialization(#[from] serde_json::Error),
62
63    #[error("I/O error: {0}")]
64    Io(#[from] std::io::Error),
65
66    #[error("invalid URL: {message}")]
67    InvalidUrl { message: String },
68
69    #[error(transparent)]
70    Core(#[from] victauri_core::VictauriError),
71}
72
73/// Convenience alias for `std::result::Result<T, PluginError>`.
74pub type Result<T> = std::result::Result<T, PluginError>;