Added generic error fn

This commit is contained in:
Franklin 2022-08-31 14:28:52 -04:00
parent 421111f880
commit b6857ea964
1 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,18 @@
use std::fmt::Display;
/// This is a wrapper for all errors. The error must implement display at least.
/// Usage:
/// ```
/// use actix_web_utils::enums::error::Error;
/// use actix_web_utils::extensions::generic_error::GenericError;
/// let generic_error = GenericError::wrap(Error::Unspecified);
/// //Use it as you please
/// ```
pub struct GenericError<E: Display> {
pub error: E
}
impl<E: Display> GenericError<E> {
pub fn wrap(e: E) -> GenericError<E>{
GenericError { error: e }
}
}