| 1 |
use thiserror::Error; |
| 2 |
|
| 3 |
pub type Result<T> = std::result::Result<T, Error>; |
| 4 |
|
| 5 |
#[derive(Debug, Error)] |
| 6 |
pub enum Error { |
| 7 |
#[error("tool not found: {0}")] |
| 8 |
ToolNotFound(String), |
| 9 |
|
| 10 |
#[error("resource not found: {0}")] |
| 11 |
ResourceNotFound(String), |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#[error("request cancelled: {0}")] |
| 17 |
Cancelled(String), |
| 18 |
|
| 19 |
#[error("invalid arguments for tool `{tool}`: {message}")] |
| 20 |
InvalidArgs { tool: String, message: String }, |
| 21 |
|
| 22 |
#[error("tool `{tool}` failed: {message}")] |
| 23 |
ToolFailed { tool: String, message: String }, |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
#[error("tool `{tool}` is not offered: {reason}")] |
| 28 |
Refused { tool: String, reason: String }, |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#[error("tool `{tool}` requires capability `{capability}` which was not granted; do not retry")] |
| 33 |
CapabilityDenied { tool: String, capability: String }, |
| 34 |
|
| 35 |
#[error("protocol error: {0}")] |
| 36 |
Protocol(String), |
| 37 |
|
| 38 |
#[error("transport error: {0}")] |
| 39 |
Transport(String), |
| 40 |
|
| 41 |
#[error(transparent)] |
| 42 |
Json(#[from] serde_json::Error), |
| 43 |
|
| 44 |
#[error(transparent)] |
| 45 |
Io(#[from] std::io::Error), |
| 46 |
|
| 47 |
#[cfg(feature = "ollama")] |
| 48 |
#[error(transparent)] |
| 49 |
Http(#[from] reqwest::Error), |
| 50 |
} |
| 51 |
|