Skip to main content

systemprompt_provider_contracts/tool/
error.rs

1//! Typed error returned by [`crate::tool::ToolProvider`] implementations.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use thiserror::Error;
7
8#[derive(Debug, Error)]
9pub enum ToolProviderError {
10    #[error("Tool '{0}' not found")]
11    ToolNotFound(String),
12
13    #[error("Service '{0}' not found")]
14    ServiceNotFound(String),
15
16    #[error("Failed to connect to service '{service}': {message}")]
17    ConnectionFailed { service: String, message: String },
18
19    #[error("Tool execution failed: {0}")]
20    ExecutionFailed(String),
21
22    #[error("Authorization failed: {0}")]
23    AuthorizationFailed(String),
24
25    #[error("Configuration error: {message}")]
26    ConfigurationError { message: String },
27
28    #[error("Configuration unavailable: {message}")]
29    Config {
30        message: String,
31        #[source]
32        source: Box<dyn std::error::Error + Send + Sync>,
33    },
34
35    #[error("Internal error: {0}")]
36    Internal(String),
37}
38
39pub type ToolProviderResult<T> = Result<T, ToolProviderError>;