diff --git a/CHANGELOG.md b/CHANGELOG.md index df4b93e..e13704d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Medullah Changelog medullah-web changelog file +## 0.19.1 (2024-09-07) +* feat(reqwest): ability to directly deserialize error response + ## 0.19.0 (2024-09-07) * refactor(rabbitmq): recreate closed channel * feat(rabbitmq): global state is now wrapped around Arc> diff --git a/Cargo.lock b/Cargo.lock index cc675a9..9be97de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1903,7 +1903,7 @@ dependencies = [ [[package]] name = "medullah-web" -version = "0.19.0" +version = "0.19.1" dependencies = [ "base64 0.22.1", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 49203a5..8e8fd8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "medullah-web" -version = "0.19.0" +version = "0.19.1" edition = "2021" license = "MIT" description = "Micro-Framework Base on Ntex" diff --git a/src/helpers/reqwest.rs b/src/helpers/reqwest.rs index d0aded9..86f2858 100644 --- a/src/helpers/reqwest.rs +++ b/src/helpers/reqwest.rs @@ -1,8 +1,9 @@ +use crate::prelude::{AppMessage, IntoAppResult}; +use crate::results::AppResult; use reqwest::StatusCode; +use serde::de::DeserializeOwned; use std::fmt::Display; -use crate::prelude::AppMessage; - pub struct ReqwestResponseError { body: String, status: StatusCode, @@ -24,6 +25,10 @@ impl ReqwestResponseError { pub fn body(&self) -> &String { &self.body } + + pub fn deserialize(&self) -> AppResult { + serde_json::from_str::(&self.body).into_app_result() + } } impl Display for ReqwestResponseError {