pub struct Error { /* private fields */ }Expand description
The error every SDK call can answer with: SPEC §6’s record, read through accessors.
It is three pointers wide — the record lives behind a box, beside an optional boxed
cause — so a Result<T, Error> stays small on the success path.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(code: ErrorCode, message: impl Into<String>) -> Error
pub fn new(code: ErrorCode, message: impl Into<String>) -> Error
An error with a code and a message. The message is bounded to
MAX_ERROR_MESSAGE_LENGTH here, so every construction site is bounded.
Sourcepub fn network_timeout(source: impl Error + Send + Sync + 'static) -> Error
pub fn network_timeout(source: impl Error + Send + Sync + 'static) -> Error
A transport failure that was a timeout: the request was sent and no answer arrived
in the transport’s own time. Retryable, and told apart from other transport failures
by Error::is_timeout where a loop treats the two differently (SPEC §16).
Sourcepub fn network(source: impl Error + Send + Sync + 'static) -> Error
pub fn network(source: impl Error + Send + Sync + 'static) -> Error
A transport failure: no connection, a timeout, a broken stream. Retryable.
Sourcepub fn network_at(origin: &str) -> Error
pub fn network_at(origin: &str) -> Error
A transport failure whose cause is not chained, for a request whose URL carries a credential (SPEC §9): only the origin is named.
Sourcepub fn malformed_response(detail: impl Into<String>) -> Error
pub fn malformed_response(detail: impl Into<String>) -> Error
A successful status whose body could not be read as the type the operation
declares: statusless, non-retryable api_error (SPEC §6).
Sourcepub fn response_too_large(limit: usize) -> Error
pub fn response_too_large(limit: usize) -> Error
A body the client refused to read past its cap.
Sourcepub fn deadline_exceeded(after: Duration) -> Error
pub fn deadline_exceeded(after: Duration) -> Error
The operation deadline passed before the call finished.
Sourcepub fn from_response(
status: StatusCode,
headers: &HeaderMap,
body: &[u8],
) -> Error
pub fn from_response( status: StatusCode, headers: &HeaderMap, body: &[u8], ) -> Error
Maps a non-2xx response onto SPEC §6’s status table, parses the body per its Error
Body Parsing and field-keyed algorithms, and reads Retry-After and X-Request-Id.
Sourcepub fn with_hint(self, hint: impl Into<String>) -> Error
pub fn with_hint(self, hint: impl Into<String>) -> Error
The same error with a hint, cut to the message cap like the message itself: a transport’s rendering of its own failure is not bounded by anyone else.
Sourcepub fn with_status(self, status: u16) -> Error
pub fn with_status(self, status: u16) -> Error
The same error carrying an HTTP status.
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> Error
pub fn with_request_id(self, request_id: impl Into<String>) -> Error
The same error carrying a request id, bounded like the message: the header is the server’s to fill.
Sourcepub fn with_retry_after(self, seconds: u32) -> Error
pub fn with_retry_after(self, seconds: u32) -> Error
The same error carrying the seconds a Retry-After header named.
Sourcepub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Error
pub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Error
The same error with a cause.
Sourcepub fn message(&self) -> &str
pub fn message(&self) -> &str
The human-readable description, at most MAX_ERROR_MESSAGE_LENGTH characters.
Sourcepub fn http_status(&self) -> Option<u16>
pub fn http_status(&self) -> Option<u16>
The HTTP status that caused the error, when one did.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether the operation can be retried.
Sourcepub fn retry_after(&self) -> Option<u32>
pub fn retry_after(&self) -> Option<u32>
The seconds Retry-After named, parsed per SPEC §6, at whatever status carried it.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
X-Request-Id, when the response carried one.
Sourcepub fn field_errors(&self) -> Option<&BTreeMap<String, Vec<String>>>
pub fn field_errors(&self) -> Option<&BTreeMap<String, Vec<String>>>
The structured 400/422 field messages, raw and untruncated. Row-keyed bodies land
here keyed by email address, then index, then position.
Sourcepub fn confirmation_people(
&self,
) -> Option<&[TemplateLibraryConfirmationPerson]>
pub fn confirmation_people( &self, ) -> Option<&[TemplateLibraryConfirmationPerson]>
The people a template-library copy needs confirmed, when a 422 named them.
Sourcepub fn body(&self) -> Option<&[u8]>
pub fn body(&self) -> Option<&[u8]>
The failure body, up to MAX_ERROR_BODY_BYTES, when the server sent one.
Sourcepub fn is_response_too_large(&self) -> bool
pub fn is_response_too_large(&self) -> bool
The answer was longer than the client will hold.
Sourcepub fn is_deadline_exceeded(&self) -> bool
pub fn is_deadline_exceeded(&self) -> bool
The operation deadline passed.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
The transport reported a timeout.
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()