pub enum AdapterError {
Auth {
reason: AuthFailureReason,
},
RateLimited {
retry_after_ms: u64,
},
Upstream {
inner: UpstreamErrorKind,
},
Validation {
field: String,
message: String,
},
SizeCapExceeded {
requested: f64,
cap: f64,
},
NotEnabled {
tool: String,
flag: String,
},
Internal {
reason: String,
},
}Expand description
Errors emitted by the adapter and surfaced over the MCP wire.
Every fallible path in the adapter ultimately produces one of these
variants. The serde representation uses an internally tagged
"kind" discriminant (#[serde(tag = "kind")]) so the JSON shape
is stable and discoverable by an LLM client.
Variants are intentionally closed — _ arms on AdapterError
are forbidden by the project’s coding rules. Add a new variant
when a structurally new error kind appears.
Variants§
Auth
Authentication / authorization failure.
Fields
reason: AuthFailureReasonWhy authentication failed.
RateLimited
Rate-limit signal from upstream. The MCP layer never silently retries (ADR-0008); it surfaces the hint so the LLM can decide.
Fields
Upstream
Upstream returned a structured error that is neither auth nor rate-limit shaped.
Fields
inner: UpstreamErrorKindWhere the error came from and the structured payload.
Validation
Input failed validation at the MCP boundary before any upstream call was made.
Fields
SizeCapExceeded
--max-order-usd cap exceeded. Trading-class concern; surfaced
here so all errors flow through one type.
NotEnabled
A tool exists but is not enabled in this binary’s configuration
(e.g. Trading without --allow-trading).
Fields
tool: StringTool name as listed in the registry. Construct via
AdapterError::not_enabled from a &'static str literal.
Internal
Last-resort variant for failures that should not propagate detail across the MCP boundary (e.g. an upstream payload that might leak a signature). The original error is logged at DEBUG with the redaction filter active.
Fields
reason: StringPre-vetted reason string. Construct via
AdapterError::internal from a &'static str literal —
never user-controlled content.
Implementations§
Source§impl AdapterError
impl AdapterError
Sourcepub fn validation(field: impl Into<String>, message: impl Into<String>) -> Self
pub fn validation(field: impl Into<String>, message: impl Into<String>) -> Self
Convenience constructor for AdapterError::Validation.
Sourcepub fn rate_limited(retry_after: Duration) -> Self
pub fn rate_limited(retry_after: Duration) -> Self
Convenience constructor for AdapterError::RateLimited from a
Duration.
Source§impl AdapterError
impl AdapterError
Sourcepub fn not_enabled(tool: &'static str, flag: &'static str) -> Self
pub fn not_enabled(tool: &'static str, flag: &'static str) -> Self
Convenience constructor for AdapterError::NotEnabled.
Sourcepub fn internal(reason: &'static str) -> Self
pub fn internal(reason: &'static str) -> Self
Convenience constructor for AdapterError::Internal.
Trait Implementations§
Source§impl Debug for AdapterError
impl Debug for AdapterError
Source§impl<'de> Deserialize<'de> for AdapterError
impl<'de> Deserialize<'de> for AdapterError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for AdapterError
impl Display for AdapterError
Source§impl Error for AdapterError
impl Error for AdapterError
1.30.0 · 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()
Source§impl From<DeribitFixError> for AdapterError
Available on crate feature fix only.
impl From<DeribitFixError> for AdapterError
fix only.Source§fn from(err: DeribitFixError) -> Self
fn from(err: DeribitFixError) -> Self
Source§impl From<Error> for AdapterError
impl From<Error> for AdapterError
Source§impl From<HttpError> for AdapterError
impl From<HttpError> for AdapterError
Source§impl From<WebSocketError> for AdapterError
impl From<WebSocketError> for AdapterError
Source§fn from(err: WebSocketError) -> Self
fn from(err: WebSocketError) -> Self
Source§impl PartialEq for AdapterError
impl PartialEq for AdapterError
Source§fn eq(&self, other: &AdapterError) -> bool
fn eq(&self, other: &AdapterError) -> bool
self and other values to be equal, and is used by ==.