#[non_exhaustive]pub enum DispatchError {
ServerNotFound(String),
ToolNotFound {
server: String,
tool: String,
},
Timeout {
server: String,
timeout_ms: u64,
},
CircuitOpen(String),
GroupPolicyDenied {
reason: String,
},
Upstream {
server: String,
message: String,
},
RateLimit(String),
Internal(Error),
}Expand description
Canonical error type for Forge dispatcher operations.
All variants are #[non_exhaustive] to allow future additions without
breaking downstream code.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ServerNotFound(String)
The requested server does not exist in the router.
ToolNotFound
The requested tool does not exist on the specified server.
Timeout
The operation timed out.
Fields
CircuitOpen(String)
The circuit breaker for this server is open.
GroupPolicyDenied
A group isolation policy denied the operation.
Upstream
An upstream MCP server returned an error.
Fields
RateLimit(String)
A rate limit was exceeded.
Internal(Error)
An internal error (catch-all for unexpected failures).
Implementations§
Source§impl DispatchError
impl DispatchError
Sourcepub fn code(&self) -> &'static str
pub fn code(&self) -> &'static str
Returns a static error code string for programmatic matching.
Sourcepub fn retryable(&self) -> bool
pub fn retryable(&self) -> bool
Returns whether the operation that produced this error may succeed if retried.
Sourcepub fn to_structured_error(&self, known_tools: Option<&[(&str, &str)]>) -> Value
pub fn to_structured_error(&self, known_tools: Option<&[(&str, &str)]>) -> Value
Convert to a structured JSON error response for LLM consumption.
Returns a JSON object with error, code, message, retryable,
and optionally suggested_fix (populated by fuzzy matching when
known_tools is provided for ToolNotFound errors).
§Arguments
known_tools- Optional list of(server, tool)pairs for fuzzy matching. Only used forToolNotFounderrors.