Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 20 variants VendoredContract { surface: &'static str, }, ContractOperation { operation: String, }, ContractParameter { operation: String, parameter: String, }, ContractPathParameter { operation: String, parameter: String, }, ContractRequiredParameter { operation: String, parameter: String, location: &'static str, }, ContractBody { operation: String, detail: &'static str, }, Contract { detail: &'static str, }, SpecPath { path: String, }, Method { method: String, }, UnknownCassette { name: String, }, UnknownMethod { cassette: String, method: String, }, Url { source: ParseError, }, NotABase, Transport { source: TransportError, }, ClientInit, ApiStatus { status: u16, endpoint: String, body: String, }, Decode { source: Error, }, BodyFile { path: String, source: Error, }, InvalidBody { source: Error, }, RenderBody { source: Error, },
}
Expand description

Anything that can go wrong driving a tapes API call.

#[snafu(module)] puts the generated context selectors in a nested error module rather than at this module’s root: the selectors are construction detail, and a consumer matches on the variants.

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

VendoredContract

The contract embedded in this build did not parse, or reduced to nothing. Only reachable from a build whose vendored document is corrupt — this crate’s own tests fail before such a build ships.

Fields

§surface: &'static str

Which contract failed.

§

ContractOperation

A caller named an operation the contract does not have. A build defect wherever the coverage gate runs, which is the point of the gate.

Fields

§operation: String

The operation id that failed to resolve.

§

ContractParameter

A caller tried to send a parameter the contract does not declare on that operation. Refused rather than sent: an undeclared parameter is exactly the drift a vendored contract exists to catch, and a server that ignores an unknown query parameter would hide it.

Fields

§operation: String

The operation being called.

§parameter: String

The undeclared wire name.

§

ContractPathParameter

A caller had no value for a path parameter the operation requires, so no URL can be built — the substitution would leave a literal {id} segment addressing nothing.

Fields

§operation: String

The operation being called.

§parameter: String

The missing path parameter.

§

ContractRequiredParameter

A caller had no value for a query or header parameter the contract marks required.

A missing path parameter cannot produce a URL at all, so it was always refused; a missing required query parameter produces a URL that is perfectly well-formed and still not a request the contract describes. The server answers it with a 400 whose wording is its own, which is a worse error later instead of a precise one now — and on an operation whose filter is what scopes the response, a client that guessed wrong about requiredness would be asking a different question than it thinks.

Fields

§operation: String

The operation being called.

§parameter: String

The missing parameter’s wire name.

§location: &'static str

Where the contract declared it: query or header.

§

ContractBody

A caller’s request body disagrees with what the operation declares.

Both directions are refusals, and the reason is the same: a body-shaped mismatch is invisible on the wire. An operation whose requestBody is required, called without one, reaches the server as a syntactically fine request that means nothing; a body sent to an operation that declares none is dropped by whatever is in front of the handler. Either way the call site looks correct.

Fields

§operation: String

The operation being called.

§detail: &'static str

What is wrong, phrased to complete the sentence.

§

Contract

The server’s response shape changed out from under this client.

Fields

§detail: &'static str

What changed.

§

SpecPath

Discovery named an OpenAPI document somewhere other than on this server. Refused rather than followed: Url::join treats an absolute URL as a replacement, so honouring it would fetch a spec from a host the user never named.

Fields

§path: String

What discovery published.

§

Method

A spec described an operation with a verb that is not an HTTP method.

Fields

§method: String

The offending verb.

§

UnknownCassette

A cassette noun parsed but is not on the surface. Only reachable if the surface changed between building the parser and dispatching.

Fields

§name: String

The noun that was invoked.

§

UnknownMethod

A cassette method parsed but is not on the cassette.

Fields

§cassette: String

The cassette that was invoked.

§method: String

The method that was invoked.

§

Url

A URL could not be built from the base and the contract’s path.

Fields

§source: ParseError

Underlying parse failure.

§

NotABase

The base URL cannot carry a path (mailto:, data:), so no route can be joined onto it.

§

Transport

The request could not be delivered.

The source is opaque on purpose. A transport may be an HTTP client, a local socket carrying opaque frames, or a test double, and this layer has no business naming any of their error types — that is precisely the coupling the seam exists to prevent. The source is rendered inline because a transport’s refusal is often the whole diagnosis — “the server answered with a redirect” is actionable, “could not reach the tapes API” alone is not — and a consumer that prints only the top-level error would otherwise lose it.

Fields

§source: TransportError

Underlying transport failure.

§

ClientInit

The transport itself could not be constructed. Requests error out rather than fall back to a client with different (redirect-following) behavior.

§

ApiStatus

The server answered with a non-success status. The body is carried because every tapes error body names the offending parameter.

Fields

§status: u16

HTTP status returned.

§endpoint: String

Endpoint that was called.

§body: String

Response body, verbatim.

§

Decode

The response could not be decoded: it is not JSON, or it is JSON that is not the type the caller asked for.

The second half is unreachable for the untyped instantiation — every JSON document is a serde_json::Value — so a decode failure on a caller-chosen model is visible exactly where that choice was made.

Fields

§source: Error

Underlying JSON failure.

§

BodyFile

--body @<path> could not be read.

Fields

§path: String

Where the read was attempted.

§source: Error

Underlying IO failure.

§

InvalidBody

--body was not JSON. Checked before sending so the failure names the quoting mistake rather than arriving as a cassette’s schema error.

Fields

§source: Error

Underlying JSON failure.

§

RenderBody

The parsed body could not be re-rendered for sending. Only reachable if serde_json emits a value it cannot serialize back.

Fields

§source: Error

Underlying JSON failure.

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, __snafu_display_formatter: &mut Formatter<'_>) -> Result

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

impl Error for Error
where Self: Debug + Display,

Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

Source§

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

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
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 ErrorCompat for Error

Source§

fn backtrace(&self) -> Option<&Backtrace>

Returns a Backtrace that may be printed.
Source§

fn iter_chain(&self) -> ChainCompat<'_, '_>
where Self: AsErrorSource,

Returns an iterator for traversing the chain of errors, starting with the current error and continuing with recursive calls to Error::source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin 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> AsErrorSource for T
where T: Error + 'static,

Source§

fn as_error_source(&self) -> &(dyn Error + 'static)

For maximum effectiveness, this needs to be called as a method to benefit from Rust’s automatic dereferencing of method receivers.
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: Sized + 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: Sized + 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> 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, 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<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