Added generic error fn
This commit is contained in:
parent
421111f880
commit
b6857ea964
@ -1,6 +1,18 @@
|
|||||||
use std::fmt::Display;
|
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 struct GenericError<E: Display> {
|
||||||
pub error: E
|
pub error: E
|
||||||
|
}
|
||||||
|
impl<E: Display> GenericError<E> {
|
||||||
|
pub fn wrap(e: E) -> GenericError<E>{
|
||||||
|
GenericError { error: e }
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user