Fixed error serialization
ci/woodpecker/push/ociImagePush Pipeline was successful Details

This commit is contained in:
Natty 2024-11-17 04:25:30 +01:00
parent 0a23953ae9
commit 11ff0ad2c0
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
1 changed files with 11 additions and 9 deletions

View File

@ -17,7 +17,7 @@ pub enum DeliveryErrorClass {
#[derive(Debug, Error, Serialize)] #[derive(Debug, Error, Serialize)]
#[error("Invalid delivery task definition: {}")] #[error("Invalid delivery task definition: {}")]
#[serde(tag = "type")] #[serde(tag = "type", content = "detail")]
pub enum InvalidDeliveryTaskError { pub enum InvalidDeliveryTaskError {
#[error("No signer with ID: {0}")] #[error("No signer with ID: {0}")]
NoSuchSigner(String), NoSuchSigner(String),
@ -33,7 +33,7 @@ pub enum InvalidDeliveryTaskError {
#[derive(Debug, Error, Serialize)] #[derive(Debug, Error, Serialize)]
#[error("Retriable task delivery failure: {}")] #[error("Retriable task delivery failure: {}")]
#[serde(tag = "type")] #[serde(tag = "type", content = "detail")]
pub enum RetriableLocalDeliveryTaskError { pub enum RetriableLocalDeliveryTaskError {
#[error("Signing error: {0}")] #[error("Signing error: {0}")]
Signing(String), Signing(String),
@ -45,7 +45,7 @@ pub enum RetriableLocalDeliveryTaskError {
#[derive(Debug, Error, Serialize)] #[derive(Debug, Error, Serialize)]
#[error("Retriable remote delivery error: {}")] #[error("Retriable remote delivery error: {}")]
#[serde(tag = "type")] #[serde(tag = "type", content = "detail")]
pub enum RetriableRemoteDeliveryError { pub enum RetriableRemoteDeliveryError {
#[error("Timeout")] #[error("Timeout")]
Timeout, Timeout,
@ -75,7 +75,7 @@ pub enum RetriableRemoteDeliveryError {
#[derive(Debug, Error, Serialize)] #[derive(Debug, Error, Serialize)]
#[error("Hard remote delivery error: {}")] #[error("Hard remote delivery error: {}")]
#[serde(tag = "type")] #[serde(tag = "type", content = "detail")]
pub enum HardRemoteDeliveryError { pub enum HardRemoteDeliveryError {
#[error("Gone")] #[error("Gone")]
Gone, Gone,
@ -98,7 +98,7 @@ pub struct DeliveryError {
} }
#[derive(Debug, Error, Serialize)] #[derive(Debug, Error, Serialize)]
#[serde(tag = "type")] #[serde(tag = "type", content = "detail")]
pub enum DeliveryErrorKind { pub enum DeliveryErrorKind {
#[error(transparent)] #[error(transparent)]
InvalidTask(#[from] InvalidDeliveryTaskError), InvalidTask(#[from] InvalidDeliveryTaskError),
@ -231,11 +231,13 @@ impl From<reqwest::Error> for DeliveryErrorKind {
} }
match value { match value {
e if e.is_connect() => RetriableRemoteDeliveryError::Connect(e.to_string()).into(), e if e.is_connect() => RetriableRemoteDeliveryError::Connect(format!("{:?}", e)).into(),
e if e.is_timeout() => RetriableRemoteDeliveryError::Timeout.into(), e if e.is_timeout() => RetriableRemoteDeliveryError::Timeout.into(),
e if e.is_decode() => RetriableRemoteDeliveryError::ResponseParse(e.to_string()).into(), e if e.is_decode() => {
e if e.is_builder() => InvalidDeliveryTaskError::Reqwest(e.to_string()).into(), RetriableRemoteDeliveryError::ResponseParse(format!("{:?}", e)).into()
e => RetriableRemoteDeliveryError::GenericReqwest(e.to_string()).into(), }
e if e.is_builder() => InvalidDeliveryTaskError::Reqwest(format!("{:?}", e)).into(),
e => RetriableRemoteDeliveryError::GenericReqwest(format!("{:?}", e)).into(),
} }
} }
} }