Updated to fit with err lib

This commit is contained in:
Franklin 2023-09-30 10:57:41 -04:00
parent ea1d463f33
commit b1394af5d7
5 changed files with 5 additions and 20 deletions

3
Cargo.lock generated
View File

@ -190,7 +190,6 @@ dependencies = [
"log",
"serde",
"serde_json",
"stdext",
]
[[package]]
@ -520,9 +519,11 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "err"
version = "0.1.1"
source = "git+https://git.franklinblanco.dev/franklinblanco/err.git#18cc77b6266d0fc90237a7ccb297d3eeb574f78a"
dependencies = [
"serde",
"sqlx",
"stdext",
"thiserror",
]

View File

@ -15,5 +15,4 @@ actix-web = "4.1.0"
serde_json = { version = "1" }
serde = { version = "1.0", features = ["derive"] }
log = { version = "0.4", features = ["serde"] }
err = { path = "../dev-deps/err" }
stdext = "0.3.1"
err = { git = "https://git.franklinblanco.dev/franklinblanco/err.git" }

View File

@ -1,7 +1,7 @@
use actix_web::{HttpResponse, http::StatusCode, web, HttpRequest, HttpResponseBuilder, body::BoxBody, Responder};
use serde::Serialize;
use err::{Error, MessageResource, Trace};
use err::Error;
/// Defines a type for actix web routes. As the current implementation of HttpResponse doesn't let you manually specify a type.
pub struct TypedResponse<B: Serialize = String> {
pub response: HttpResponse<Option<web::Json<Result<B, Error>>>>,

View File

@ -2,5 +2,4 @@ pub mod extensions;
pub mod utils;
pub use extensions::typed_response::TypedResponse;
pub use extensions::service_response::ServiceResponse;
pub use stdext::function_name;
pub use extensions::service_response::ServiceResponse;

View File

@ -1,19 +1,5 @@
/// Macro used to generate the trace object, must be called from the place where it originates, don't call from another function.
#[allow(unused_macros)]
#[macro_export]
macro_rules! trace {
() => {
dtos::dtos::feature_less::message_resource::Trace {
line: line!(),
function: actix_web_utils::function_name!().into(),
file: file!().into(),
service: env!("CARGO_PKG_NAME").into(),
}
};
}
/// # Unwrap result or return service response
/// Unwraps or turns Result<T, Error> -> ServiceResponse error variant
#[allow(unused_macros)]