1
0
Fork 0

Merge pull request 'add source reqwest error to ForgejoError::BadStructure' (#12) from bad-structure-source into main

Reviewed-on: https://codeberg.org/Cyborus/forgejo-api/pulls/12
This commit is contained in:
Cyborus 2023-11-19 18:13:20 +00:00
commit b534e502d1

View file

@ -27,7 +27,7 @@ pub enum ForgejoError {
#[error("API key should be ascii")] #[error("API key should be ascii")]
KeyNotAscii, KeyNotAscii,
#[error("the response from forgejo was not properly structured")] #[error("the response from forgejo was not properly structured")]
BadStructure, BadStructure(#[source] reqwest::Error),
#[error("unexpected status code {} {}", .0.as_u16(), .0.canonical_reason().unwrap_or(""))] #[error("unexpected status code {} {}", .0.as_u16(), .0.canonical_reason().unwrap_or(""))]
UnexpectedStatusCode(StatusCode), UnexpectedStatusCode(StatusCode),
#[error("{} {}: {}", .0.as_u16(), .0.canonical_reason().unwrap_or(""), .1)] #[error("{} {}: {}", .0.as_u16(), .0.canonical_reason().unwrap_or(""), .1)]
@ -37,7 +37,7 @@ pub enum ForgejoError {
impl From<reqwest::Error> for ForgejoError { impl From<reqwest::Error> for ForgejoError {
fn from(e: reqwest::Error) -> Self { fn from(e: reqwest::Error) -> Self {
if e.is_decode() { if e.is_decode() {
ForgejoError::BadStructure ForgejoError::BadStructure(e)
} else { } else {
ForgejoError::ReqwestError(e) ForgejoError::ReqwestError(e)
} }