Added macro to wrap errors

This commit is contained in:
Franklin 2022-08-31 14:36:52 -04:00
parent b6857ea964
commit dfab97d9fe

View File

@ -25,4 +25,16 @@ macro_rules! unwrap_or_return_handled_error {
Err(error) => return actix_web_utils::traits::macro_traits::ReturnableErrorShape::convert_to_returnable::<$type_of_resp>(&error, $error_status_code) Err(error) => return actix_web_utils::traits::macro_traits::ReturnableErrorShape::convert_to_returnable::<$type_of_resp>(&error, $error_status_code)
} }
} }
}
/// Takes whatever error you supply to it and wraps it in a GenericError<E> if err
#[allow(unused_macros)]
#[macro_export]
macro_rules! wrap_generic_error_in_wrapper {
( $e:expr ) => {
match $e {
Ok(value) => value,
Err(error) => actix_web_utils::extensions::generic_error::GenericError::wrap(error),
}
}
} }