#[non_exhaustive]pub enum Error {
Api {
status: u16,
detail: Value,
},
Refused {
status: u16,
response: Box<GenerateResponse>,
},
Transport(Box<dyn Error + Send + Sync + 'static>),
Decode(Error),
}Expand description
What went wrong with a call.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Api
The server answered with a non-2xx status.
detail is the response’s detail field when the body is a JSON
object that has one (a string, or an array of field errors for a
422), the whole JSON body otherwise, or the raw text as a JSON
string when the body is not JSON.
Fields
Refused
The server refused to generate a document: a 422 from a generate
call whose body is a GenerateResponse with success: false and
no xml.
response carries the findings, typed: validation_errors for rows
that failed field checks and scheme_violations for scheme-rulebook
breaches. Error::status still returns the HTTP status.
Fields
response: Box<GenerateResponse>The decoded refusal, with success: false and no xml.
Transport(Box<dyn Error + Send + Sync + 'static>)
The request did not complete: connection refused, timeout, TLS, an invalid URL, or a body that could not be read.
Decode(Error)
A 2xx response body did not match the expected shape.
Implementations§
Source§impl Error
impl Error
Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
The HTTP status for Error::Api, None for the other kinds.
Sourcepub fn refusal(&self) -> Option<&GenerateResponse>
pub fn refusal(&self) -> Option<&GenerateResponse>
The refused generation for Error::Refused, None for the other
kinds: its validation_errors and scheme_violations say why.
Sourcepub fn request_errors(&self) -> Option<Vec<RequestError>>
pub fn request_errors(&self) -> Option<Vec<RequestError>>
The items of a 422 response’s detail array, typed: Some only
for Error::Api whose detail is an array of FastAPI request
errors (for example an unknown message type).
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()