use std::fmt;
#[derive(Debug, thiserror::Error)]
pub enum ViiperError {
#[error("transport error: {0}")]
Io(#[from] std::io::Error),
#[error("{0}")]
Protocol(#[from] ProblemJson),
#[error("parse error: {0}")]
Parse(#[from] serde_json::Error),
#[error("unexpected response: {0}")]
UnexpectedResponse(String),
#[cfg(feature = "async")]
#[error("operation timed out")]
Timeout,
}
#[derive(Debug, Clone, serde::Deserialize)]
pub struct ProblemJson {
pub status: u16,
pub title: String,
pub detail: String,
}
impl fmt::Display for ProblemJson {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} {}: {}", self.status, self.title, self.detail)
}
}
impl std::error::Error for ProblemJson {}