diff --git a/Cargo.lock b/Cargo.lock index 96667d5..3f0cf63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -183,11 +183,11 @@ dependencies = [ [[package]] name = "actix-web-utils" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ebb116655f5320fb6c805b011884f54980df2e88fce92758bdd5b0579032e15" +version = "0.2.21" +source = "git+https://github.com/franklinblanco/actix-web-utils.git#416e44e849a4911fde589424a703236585192365" dependencies = [ "actix-web", + "err", "log", "serde", "serde_json", @@ -423,6 +423,7 @@ version = "0.1.0" dependencies = [ "actix-web-utils", "dev-dtos", + "err", "reqwest", "serde", "tokio", @@ -431,7 +432,7 @@ dependencies = [ [[package]] name = "dev-dtos" version = "0.1.0" -source = "git+https://backend:Eo1n1TPsyWV7wwo9uFwgUJGKKheMM6paM2mDkVPA4zqkh5dt6Q6XPkbtojzYQudQsM84vSwKmhHHTPjyn535d6NLBmA3meeGj0Gb8if4sceAwvySdmzedg5mN2P5zzQt@gitea.blancoinfante.com/blancoinfante_backend/dev-dtos-rust.git#80abf74269baf13b9fc1d186516564b0d4521270" +source = "git+https://github.com/franklinblanco/user-dtos.git#3b3ffde695753edb4e7ffdf722299b372f2c0bd0" dependencies = [ "chrono", "serde", @@ -456,6 +457,14 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "err" +version = "0.1.1" +source = "git+https://github.com/franklinblanco/err.git#42237f4a4be71530933f920f7e5eb6dbf1d0c75e" +dependencies = [ + "serde", +] + [[package]] name = "fastrand" version = "1.8.0" diff --git a/Cargo.toml b/Cargo.toml index 2d9556b..bdd6ed3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,8 @@ edition = "2021" tokio = { version = "1.20.1", features = ["full"] } reqwest = { version = "0.11.11", features = [ "json", "blocking" ]} serde = { version = "1.0", features = ["derive"] } -actix-web-utils = "0.2.5" #openssl = { version = "0.10", features = ["vendored"] } -dev-dtos = { git = "https://backend:Eo1n1TPsyWV7wwo9uFwgUJGKKheMM6paM2mDkVPA4zqkh5dt6Q6XPkbtojzYQudQsM84vSwKmhHHTPjyn535d6NLBmA3meeGj0Gb8if4sceAwvySdmzedg5mN2P5zzQt@gitea.blancoinfante.com/blancoinfante_backend/dev-dtos-rust.git" } \ No newline at end of file +err = { git = "https://github.com/franklinblanco/err.git" } +dev-dtos = { git = "https://github.com/franklinblanco/user-dtos.git" } +actix-web-utils = { git = "https://github.com/franklinblanco/actix-web-utils.git" } \ No newline at end of file diff --git a/src/middleware/client.rs b/src/middleware/client.rs index a0a49a4..dc6be78 100644 --- a/src/middleware/client.rs +++ b/src/middleware/client.rs @@ -1,4 +1,4 @@ -use actix_web_utils::{enums::error::Error, dtos::message::MessageResource}; +use err::{Error, MessageResource}; use reqwest::Client; use serde::{Serialize, de::DeserializeOwned}; @@ -31,7 +31,7 @@ pub async fn perform_request( true => { match res.json::().await { Ok(resp_dto) => Ok(resp_dto), // Return correctly deserialized obj - Err(err) => Err(Error::ClientError(MessageResource::new_from_err(err))), + Err(err) => Err(Error::Serde(MessageResource::from(err))), } } false => { @@ -41,7 +41,7 @@ pub async fn perform_request( res.status().as_u16(), match res.json::>().await { Ok(messages) => messages, - Err(e) => vec![MessageResource::new_from_err(e.to_string())], + Err(e) => vec![MessageResource::from(e)], }, )) } @@ -49,7 +49,7 @@ pub async fn perform_request( } Err(e) => { // Request couldn't be sent - Err(Error::ClientError(MessageResource::new_from_err(e))) + Err(Error::Network(MessageResource::from(e))) } } } @@ -84,7 +84,7 @@ pub async fn perform_request_without_client( true => { match res.json::().await { Ok(resp_dto) => Ok(resp_dto), // Return correctly deserialized obj - Err(err) => Err(Error::ClientError(MessageResource::new_from_err(err))), + Err(err) => Err(Error::Serde(MessageResource::from(err))), } } false => { @@ -94,7 +94,7 @@ pub async fn perform_request_without_client( res.status().as_u16(), match res.json::>().await { Ok(messages) => messages, - Err(e) => vec![MessageResource::new_from_err(e.to_string())], + Err(e) => vec![MessageResource::from(e)], }, )) } @@ -102,7 +102,7 @@ pub async fn perform_request_without_client( } Err(e) => { // Request couldn't be sent - Err(Error::ClientError(MessageResource::new_from_err(e))) + Err(Error::Network(MessageResource::from(e))) } } } @@ -136,7 +136,7 @@ pub fn perform_request_without_client_sync( true => { match res.json::() { Ok(resp_dto) => Ok(resp_dto), // Return correctly deserialized obj - Err(err) => Err(Error::ClientError(MessageResource::new_from_err(err))), + Err(err) => Err(Error::Serde(MessageResource::from(err))), } } false => { @@ -146,7 +146,7 @@ pub fn perform_request_without_client_sync( res.status().as_u16(), match res.json::>() { Ok(messages) => messages, - Err(e) => vec![MessageResource::new_from_err(e.to_string())], + Err(e) => vec![MessageResource::from(e)], }, )) } @@ -154,7 +154,7 @@ pub fn perform_request_without_client_sync( } Err(e) => { // Request couldn't be sent - Err(Error::ClientError(MessageResource::new_from_err(e))) + Err(Error::Network(MessageResource::from(e))) } } } \ No newline at end of file diff --git a/src/middleware/user_svc/user_service.rs b/src/middleware/user_svc/user_service.rs index 70d6e3c..f1d71fc 100644 --- a/src/middleware/user_svc/user_service.rs +++ b/src/middleware/user_svc/user_service.rs @@ -1,5 +1,5 @@ -use actix_web_utils::enums::error::Error; use dev_dtos::{dtos::user::user_dtos::{UserForCreationDto, UserForLoginDto, UserForAuthenticationDto}, domain::user::{user::User, token::Token}}; +use err::Error; use reqwest::{Client, Method}; use crate::middleware::client::perform_request;