feat: handle reqwest errors
ci/woodpecker/push/woodpecker Pipeline failed Details

This commit is contained in:
Aravinth Manivannan 2022-12-31 02:23:43 +05:30
parent 86d56734cf
commit 2b87ad09a7
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
3 changed files with 16 additions and 12 deletions

View File

@ -48,8 +48,7 @@ impl Conductor {
.bearer_auth(&c.api_key)
.json(e)
.send()
.await
.unwrap();
.await?;
}
Ok(())
}

View File

@ -37,8 +37,7 @@ impl Ctx {
.bearer_auth(&self.settings.form.api_key)
.json(payload)
.send()
.await
.unwrap();
.await?;
Ok(())
}
@ -60,11 +59,9 @@ impl Ctx {
.bearer_auth(&self.settings.form.api_key)
.json(payload)
.send()
.await
.unwrap()
.await?
.json()
.await
.unwrap();
.await?;
Ok(res)
}
@ -84,11 +81,9 @@ impl Ctx {
.get(form_url)
.bearer_auth(&self.settings.form.api_key)
.send()
.await
.unwrap()
.await?
.json()
.await
.unwrap();
.await?;
Ok(res)
}
}

View File

@ -30,7 +30,9 @@ use derive_more::{Display, Error};
use git2::Error as GitError;
use hmac::digest::InvalidLength;
use hmac::digest::MacError;
use reqwest::Error as ReqwestError;
use serde::{Deserialize, Serialize};
use tracing::error;
use url::ParseError;
use crate::page::Page;
@ -186,6 +188,14 @@ pub enum ServiceError {
WebhookNotFound,
}
impl From<ReqwestError> for ServiceError {
#[cfg(not(tarpaulin_include))]
fn from(e: ReqwestError) -> ServiceError {
error!("{}", e);
ServiceError::InternalServerError
}
}
impl From<InvalidLength> for ServiceError {
#[cfg(not(tarpaulin_include))]
fn from(_: InvalidLength) -> ServiceError {