#[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,
},
TransportDead {
server: String,
reason: String,
},
ToolError {
server: String,
tool: 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 at the transport or RPC level.
This indicates a potential server health issue (connection refused, broken pipe, JSON-RPC protocol error). The server may be down or malfunctioning.
Fields
TransportDead
The transport to the server has died permanently (pipe broken, channel closed). Unlike Upstream (transient), this requires reconnection before further calls succeed.
Fields
ToolError
A tool returned an application-level error (MCP isError: true).
The downstream server is healthy — the tool processed the request but returned an error (e.g., bad parameters, missing prerequisite state). This does NOT indicate a server health issue.
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 trips_circuit_breaker(&self) -> bool
pub fn trips_circuit_breaker(&self) -> bool
Whether this error indicates the server is unhealthy and should count toward the circuit breaker failure threshold.
Returns true for errors suggesting the server is down or unresponsive
(Timeout, Upstream transport/RPC failures, Internal).
Returns false for errors where the server responded coherently but the
request was invalid (ToolError, ToolNotFound, etc).
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.
Trait Implementations§
Source§impl Debug for DispatchError
impl Debug for DispatchError
Source§impl Display for DispatchError
impl Display for DispatchError
Source§impl Error for DispatchError
impl Error for DispatchError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()