spec_ai_plugin/
error.rs

1//! Plugin-specific error types
2
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Errors that can occur during plugin loading and execution
7#[derive(Error, Debug)]
8pub enum PluginError {
9    /// Plugin directory is not a directory
10    #[error("Plugin directory is not a directory: {0}")]
11    NotADirectory(PathBuf),
12
13    /// Failed to load plugin from file
14    #[error("Failed to load plugin from {path}: {message}")]
15    LoadFailed { path: PathBuf, message: String },
16
17    /// Plugin API version doesn't match host
18    #[error("Plugin API version mismatch: expected {expected}, found {found} in {path}")]
19    VersionMismatch {
20        expected: u32,
21        found: u32,
22        path: PathBuf,
23    },
24
25    /// Duplicate plugin name
26    #[error("Duplicate plugin name: {0}")]
27    DuplicatePlugin(String),
28
29    /// Duplicate tool name
30    #[error("Duplicate tool name '{tool}' from plugin '{plugin}'")]
31    DuplicateTool { tool: String, plugin: String },
32
33    /// Invalid tool info from plugin
34    #[error("Invalid tool info from plugin: {0}")]
35    InvalidToolInfo(String),
36
37    /// Plugin execution failed
38    #[error("Plugin execution failed: {0}")]
39    ExecutionFailed(String),
40}