Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 19 variants InvalidBaseUrl(String), UrlNotABase { url: String, }, Http(Error), UpstreamStatus { endpoint: &'static str, status: u16, body_preview: Option<String>, }, Unknown { endpoint: &'static str, }, Decode { endpoint: String, status: u16, message: String, }, BadRequest(String), MissingQuery { name: &'static str, }, Header { name: &'static str, source: InvalidHeaderValue, }, Api(Box<dyn Error + Send + Sync + 'static>), SymbolNotFound { symbol: String, }, BadConid { symbol: String, raw: String, source: ParseIntError, }, WsHandshake { url: String, source: Error, }, WsTransport { source: Error, }, WsProtocol(String), ResponseBuild(String), NotAuthenticated, NoSession, Other(String),
}
Expand description

Errors that can arise when talking to the Client Portal Gateway.

The enum is #[non_exhaustive] — match on the variants you care about and handle the rest via a catch-all so adding new variants in a point release is not a breaking change.

§Retry hints

Use Error::is_retryable in retry loops rather than pattern-matching every variant. Transient transport failures, upstream 5xx, and NoSession are flagged retryable; caller-input errors and auth failures are not.

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.
§

InvalidBaseUrl(String)

The base URL passed to Client::new could not be parsed.

§

UrlNotABase

A URL we tried to manipulate isn’t suitable as a base — either the scheme can’t have a hierarchical path (data:, mailto:) or the URL has no host. Distinct from Error::InvalidBaseUrl because it surfaces during a call rather than at builder time.

Fields

§url: String

The URL whose base manipulation failed.

§

Http(Error)

HTTP transport failure (DNS, connection, TLS, timeouts).

§

UpstreamStatus

CPGateway returned a non-2xx status. Carries the endpoint name, the upstream status code, and (where cheap) a short body preview. Replaces a swathe of older Error::Other("upstream 500")-style sites — callers can now branch on .status for retry logic.

Fields

§endpoint: &'static str

The endpoint that returned the bad status, e.g. iserver/auth/status.

§status: u16

The HTTP status code received.

§body_preview: Option<String>

First few hundred bytes of the response body, if cheap to capture.

§

Unknown

CPGateway returned a status code our typed client doesn’t model. Useful canary for OpenAPI spec drift — when a previously-undocumented status appears in production, this surfaces the endpoint name so telemetry can flag it without losing every detail to a string.

Fields

§endpoint: &'static str

The endpoint whose response shape was unexpected.

§

Decode

A JSON response body could not be decoded into the expected type — typically a sign the Gateway sent an HTML error page on top of a 2xx status (Akamai error pages, maintenance banners, etc.).

Fields

§endpoint: String

The endpoint whose body failed to decode.

§status: u16

The HTTP status code on the response that failed to decode.

§message: String

The underlying serde error, stringified.

§

BadRequest(String)

Caller-provided input was malformed (bad query parameter, oversize body, unparseable URL, etc.). Distinct from Error::Other so HTTP wrappers can map it to 400 rather than 500.

§

MissingQuery

A required query parameter was absent. Distinct from Error::BadRequest so HTTP wrappers can map to a more specific error code and so callers can hint the user about what’s missing.

Fields

§name: &'static str

The query-parameter name that was expected but absent.

§

Header

HTTP header construction failed — the value contained bytes the http crate refuses to put on the wire (control chars, non-visible ASCII, CR/LF). Carries the header name + the underlying parse error.

Fields

§name: &'static str

The header name we tried to construct.

§source: InvalidHeaderValue

The underlying value-validation failure.

§

Api(Box<dyn Error + Send + Sync + 'static>)

An error bubbled up from the generated API layer. The inner boxed error is whatever the generated client raised — this keeps bezant-core’s public API free of a versioned anyhow type.

§

SymbolNotFound

Symbol → conid lookup returned no contracts. Distinct from Error::UpstreamStatus because the upstream returned a well-formed empty result, not a failure.

Fields

§symbol: String

The symbol that returned no contracts.

§

BadConid

A contract IBKR returned for a symbol carried a conid that couldn’t be parsed as i32 — surfaces as a typed signal so callers don’t have to string-match on Error::Other.

Fields

§symbol: String

The symbol whose contract carried a bad conid.

§raw: String

The raw string IBKR returned where a number was expected.

§source: ParseIntError

The underlying parse error.

§

WsHandshake

WebSocket handshake (HTTP upgrade) failed. Carries the URL we were upgrading to plus the underlying tungstenite error so a caller can branch on TLS vs DNS vs auth failures.

Fields

§url: String

The WebSocket URL the handshake targeted.

§source: Error

The underlying tungstenite error.

§

WsTransport

WebSocket transport (read/write/close) failed mid-stream.

Fields

§source: Error

The underlying tungstenite error.

§

WsProtocol(String)

WebSocket protocol violation or bezant-side serialisation issue.

§

ResponseBuild(String)

Failed to construct an HTTP response — body assembly or header validation. Server-side internal; shouldn’t be observable in normal operation.

§

NotAuthenticated

The Gateway reports we are not authenticated — the user needs to log in via the Gateway’s browser UI.

§

NoSession

The Gateway is reachable but has no active session (e.g. was just booted, or session was invalidated by another login).

§

Other(String)

A catch-all for unexpected conditions that don’t fit other variants. Prefer adding a typed variant — this is the documented escape hatch of last resort, and is mapped to a generic 500 at the HTTP boundary.

Implementations§

Source§

impl Error

Source

pub fn other(msg: impl Into<String>) -> Self

Construct a free-form error.

Prefer a typed variant — Error::Other maps to a generic 500 at the HTTP boundary and gives callers no programmatic handle.

Source

pub fn is_retryable(&self) -> bool

Hint for retry loops: returns true iff this error might succeed on retry. Use this in backoff loops instead of pattern-matching every variant by hand.

Retryable:

  • Transport timeouts / connect failures / general request errors
  • Upstream 5xx and 429 (rate-limited)
  • NoSession (session may come back)
  • WebSocket transport failures (reconnect)

Not retryable:

  • Caller-input errors (BadRequest, MissingQuery, InvalidBaseUrl, UrlNotABase)
  • Auth failures (NotAuthenticated)
  • SymbolNotFound, BadConid, Header (data-shape problems)
  • Decode / Api / Unknown (semantically broken response)
  • Other (unknown — be conservative, don’t retry)

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl !UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ValidateIp for T
where T: ToString,

Source§

fn validate_ipv4(&self) -> bool

Validates whether the given string is an IP V4
Source§

fn validate_ipv6(&self) -> bool

Validates whether the given string is an IP V6
Source§

fn validate_ip(&self) -> bool

Validates whether the given string is an IP
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more