pub struct ErrorDetails {
pub status_code: u16,
pub error_code: String,
pub message: Option<ErrorMessage>,
pub response_id: Option<String>,
}Expand description
The error envelope every Timeweb Cloud error response shares.
The generated operations type each error body per operation and status, which makes uniform handling (logging, user messages) awkward. All those bodies carry the same envelope, and this type extracts it from any operation error without naming the per-operation entity:
use timeweb_rs::{ErrorDetails, apis::servers_api};
let config = timeweb_rs::authenticated("your-jwt-token");
if let Err(error) = servers_api::get_server(&config, 42).await {
if let Some(details) = ErrorDetails::from_api_error(&error) {
eprintln!("{}: {}", details.status_code, details.messages().join("; "));
}
}Fields§
§status_code: u16HTTP status code repeated in the body.
error_code: StringMachine-readable error identifier.
message: Option<ErrorMessage>One or several human-readable messages.
response_id: Option<String>Request correlation id for support tickets.
Implementations§
Source§impl ErrorDetails
impl ErrorDetails
Sourcepub fn from_api_error<E>(error: &Error<E>) -> Option<Self>
pub fn from_api_error<E>(error: &Error<E>) -> Option<Self>
Extracts the error envelope from any operation error.
Returns None for transport, serialization and IO errors, and for
response bodies that do not carry the envelope.
Trait Implementations§
Source§impl Clone for ErrorDetails
impl Clone for ErrorDetails
Source§fn clone(&self) -> ErrorDetails
fn clone(&self) -> ErrorDetails
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ErrorDetails
impl Debug for ErrorDetails
Source§impl<'de> Deserialize<'de> for ErrorDetails
impl<'de> Deserialize<'de> for ErrorDetails
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ErrorDetails
Source§impl PartialEq for ErrorDetails
impl PartialEq for ErrorDetails
impl StructuralPartialEq for ErrorDetails
Auto Trait Implementations§
impl Freeze for ErrorDetails
impl RefUnwindSafe for ErrorDetails
impl Send for ErrorDetails
impl Sync for ErrorDetails
impl Unpin for ErrorDetails
impl UnsafeUnpin for ErrorDetails
impl UnwindSafe for ErrorDetails
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more