From a6053b8eee8ae2d57c0bb9d1973ea652f6ccd166 Mon Sep 17 00:00:00 2001 From: "Jesper L. Nielsen" Date: Thu, 29 Feb 2024 16:09:42 +0100 Subject: [PATCH] fix: return values unified The return values was not used. On POST the HTTP error code is returned as an enum. --- plugins/upload/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/upload/src/lib.rs b/plugins/upload/src/lib.rs index 2b69babbbf..04a3d1123b 100644 --- a/plugins/upload/src/lib.rs +++ b/plugins/upload/src/lib.rs @@ -29,6 +29,8 @@ pub enum Error { Request(#[from] reqwest::Error), #[error("{0}")] ContentLength(String), + #[error("{0}")] + HttpErrorCode(u16), } impl Serialize for Error { @@ -100,7 +102,8 @@ async fn upload( // Create the request and attach the file to the body let client = reqwest::Client::new(); - let mut request = client.post(url) + let mut request = client + .post(url) .header(reqwest::header::CONTENT_LENGTH, file_len) .body(file_to_body(id, window, file)); @@ -114,10 +117,7 @@ async fn upload( if response.status().is_success() { return response.text().await.map_err(Error::from); } - Err(Error::ContentLength(format!( - "invalid status code: {}", - response.status().as_u16() - ))) + Err(Error::HttpErrorCode(response.status().as_u16())) } fn file_to_body(id: u32, window: Window, file: File) -> reqwest::Body {