Skip to main content

oci_core/core/
errors.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum OciError {
5    #[error("Network error: {0}")]
6    Network(String),
7    #[error("Invalid response: {0}")]
8    InvalidResponse(String),
9    #[error("Authentication error: {0}")]
10    Auth(String),
11    #[error("Reference error: {0}")]
12    Reference(String),
13    #[error("IO error: {0}")]
14    Io(String),
15    #[error("Upload session reset required: {0}")]
16    UploadReset(String),
17    #[error("Push error: {0}")]
18    PushError(String),
19    #[error("Unexpected status {status}: {message}")]
20    Status { status: u16, message: String },
21}
22
23impl From<reqwest::Error> for OciError {
24    fn from(value: reqwest::Error) -> Self {
25        OciError::Network(value.to_string())
26    }
27}
28
29impl From<std::io::Error> for OciError {
30    fn from(value: std::io::Error) -> Self {
31        OciError::Io(value.to_string())
32    }
33}