Added macros and err lib to local
This commit is contained in:
parent
b1394af5d7
commit
86e5626f7c
|
@ -519,7 +519,6 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
|||
[[package]]
|
||||
name = "err"
|
||||
version = "0.1.1"
|
||||
source = "git+https://git.franklinblanco.dev/franklinblanco/err.git#18cc77b6266d0fc90237a7ccb297d3eeb574f78a"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"sqlx",
|
||||
|
|
|
@ -15,4 +15,4 @@ actix-web = "4.1.0"
|
|||
serde_json = { version = "1" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
log = { version = "0.4", features = ["serde"] }
|
||||
err = { git = "https://git.franklinblanco.dev/franklinblanco/err.git" }
|
||||
err = { path = "/Users/franklinblanco/Desktop/Code/rust/libs/dev-deps/err" }
|
|
@ -8,7 +8,7 @@ macro_rules! u_res_or_sr {
|
|||
( $e:expr ) => {
|
||||
match $e {
|
||||
Ok(result) => result,
|
||||
Err(error) => return Err((500, error.push_trace(actix_web_utils::trace!())))
|
||||
Err(error) => return Err((500, error.push_trace(err::trace!())))
|
||||
}
|
||||
};
|
||||
( $e:expr, $status:expr ) => {
|
||||
|
@ -53,6 +53,24 @@ macro_rules! u_res_or_res {
|
|||
};
|
||||
}
|
||||
|
||||
/// Macro used to 'unwrap' a result that returns an unknown error type
|
||||
#[allow(unused_macros)]
|
||||
#[macro_export]
|
||||
macro_rules! x_u_res_or_sr {
|
||||
( $e:expr, $se:expr ) => {
|
||||
match $e {
|
||||
Ok(result) => result,
|
||||
Err(error) => return Err((400, err::Error::new(err::trace!()).error_type(err::ErrorType::Service($se))))
|
||||
}
|
||||
};
|
||||
( $e:expr, $se:expr, $status:expr ) => {
|
||||
match $e {
|
||||
Ok(result) => result,
|
||||
Err(error) => return Err($status, err::Error::new(err::trace!()).typed(err::error_type(err::ErrorType::Service($se))))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unused_macros)]
|
||||
#[macro_export]
|
||||
macro_rules! x_e_res_or_db {
|
||||
|
@ -65,3 +83,24 @@ macro_rules! x_e_res_or_db {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unused_macros)]
|
||||
#[macro_export]
|
||||
macro_rules! x_u_res_db_or_sr {
|
||||
( $e:expr ) => {
|
||||
match $e {
|
||||
Ok(value) => value,
|
||||
Err(error) => {
|
||||
return Err((500, err::Error::new(err::trace!()).error_type(err::ErrorType::Service(err::ServiceError::DatabaseError(error)))))
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unused_macros)]
|
||||
#[macro_export]
|
||||
macro_rules! service_error {
|
||||
( $status:expr, $errtype:expr ) => {
|
||||
Err(($status, err::Error::new(err::trace!()).error_type(err::ErrorType::Service($errtype))))
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue