#[non_exhaustive]pub enum ToolError {
InvalidParams {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
NotFound(String),
Unauthorized(String),
Forbidden(String),
Timeout {
timeout_ms: u64,
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Internal {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Custom {
code: String,
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Json(Error),
Io(Error),
}Expand description
Tool execution error
Uses #[non_exhaustive] to allow future expansion without breaking changes.
Supports error chaining via #[source].
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
InvalidParams
Invalid parameters
NotFound(String)
Tool not found
Unauthorized access
Forbidden(String)
Forbidden
Timeout
Timeout
Internal
Internal error
Custom
Custom error with code
Json(Error)
JSON serialization/deserialization error
Io(Error)
IO error
Implementations§
Source§impl ToolError
impl ToolError
Sourcepub fn invalid_params(message: impl Into<String>) -> Self
pub fn invalid_params(message: impl Into<String>) -> Self
Create invalid parameters error
Sourcepub fn invalid_params_with_source(
message: impl Into<String>,
source: impl Error + Send + Sync + 'static,
) -> Self
pub fn invalid_params_with_source( message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self
Create invalid parameters error with source
Create unauthorized error
Sourcepub fn timeout_with_source(
timeout_ms: u64,
message: impl Into<String>,
source: impl Error + Send + Sync + 'static,
) -> Self
pub fn timeout_with_source( timeout_ms: u64, message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self
Create timeout error with source
Sourcepub fn internal_with_source(
message: impl Into<String>,
source: impl Error + Send + Sync + 'static,
) -> Self
pub fn internal_with_source( message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self
Create internal error with source
Sourcepub fn custom_with_source(
code: impl Into<String>,
message: impl Into<String>,
source: impl Error + Send + Sync + 'static,
) -> Self
pub fn custom_with_source( code: impl Into<String>, message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self
Create custom error with source
Sourcepub fn has_source(&self) -> bool
pub fn has_source(&self) -> bool
Check if error has source
Trait Implementations§
Source§impl Error for ToolError
impl Error for ToolError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for ToolError
impl !RefUnwindSafe for ToolError
impl Send for ToolError
impl Sync for ToolError
impl Unpin for ToolError
impl UnsafeUnpin for ToolError
impl !UnwindSafe for ToolError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more