mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 07:53:00 +01:00
Merge pull request #218 from Dowwie/master
added error response functions for 501,502,503,504
This commit is contained in:
commit
5f5ddc8f01
42
src/error.rs
42
src/error.rs
@ -757,6 +757,48 @@ where
|
|||||||
InternalError::new(err, StatusCode::INTERNAL_SERVER_ERROR).into()
|
InternalError::new(err, StatusCode::INTERNAL_SERVER_ERROR).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper function that creates wrapper of any error and
|
||||||
|
/// generate *NOT IMPLEMENTED* response.
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn ErrorNotImplemented<T>(err: T) -> Error
|
||||||
|
where
|
||||||
|
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
|
||||||
|
{
|
||||||
|
InternalError::new(err, StatusCode::NOT_IMPLEMENTED).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Helper function that creates wrapper of any error and
|
||||||
|
/// generate *BAD GATEWAY* response.
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn ErrorBadGateway<T>(err: T) -> Error
|
||||||
|
where
|
||||||
|
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
|
||||||
|
{
|
||||||
|
InternalError::new(err, StatusCode::BAD_GATEWAY).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Helper function that creates wrapper of any error and
|
||||||
|
/// generate *SERVICE UNAVAILABLE* response.
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn ErrorServiceUnavailable<T>(err: T) -> Error
|
||||||
|
where
|
||||||
|
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
|
||||||
|
{
|
||||||
|
InternalError::new(err, StatusCode::SERVICE_UNAVAILABLE).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Helper function that creates wrapper of any error and
|
||||||
|
/// generate *GATEWAY TIMEOUT* response.
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn ErrorGatewayTimeout<T>(err: T) -> Error
|
||||||
|
where
|
||||||
|
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
|
||||||
|
{
|
||||||
|
InternalError::new(err, StatusCode::GATEWAY_TIMEOUT).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
Loading…
Reference in New Issue
Block a user