viiper_client/
error.rs

1// This file is auto-generated by VIIPER codegen. DO NOT EDIT.
2
3use std::fmt;
4
5/// Errors that can occur when using the VIIPER client
6#[derive(Debug, thiserror::Error)]
7pub enum ViiperError {
8    /// Network or I/O errors
9    #[error("transport error: {0}")]
10    Io(#[from] std::io::Error),
11    
12    /// RFC 7807 Problem+JSON response from server
13    #[error("{0}")]
14    Protocol(#[from] ProblemJson),
15    
16    /// Failed to parse JSON response
17    #[error("parse error: {0}")]
18    Parse(#[from] serde_json::Error),
19    
20    /// Unexpected response format
21    #[error("unexpected response: {0}")]
22    UnexpectedResponse(String),
23    
24    /// Operation timed out
25    #[cfg(feature = "async")]
26    #[error("operation timed out")]
27    Timeout,
28}
29
30/// RFC 7807 Problem Details for HTTP APIs
31#[derive(Debug, Clone, serde::Deserialize)]
32pub struct ProblemJson {
33    pub status: u16,
34    pub title: String,
35    pub detail: String,
36}
37
38impl fmt::Display for ProblemJson {
39    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40        write!(f, "{} {}: {}", self.status, self.title, self.detail)
41    }
42}
43
44impl std::error::Error for ProblemJson {}