From 8b473745cb4b27ae4773393cc0b0024bf389f196 Mon Sep 17 00:00:00 2001 From: dowwie Date: Thu, 10 May 2018 11:26:38 -0400 Subject: [PATCH] added error response functions for 501,502,503,504 --- src/error.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/error.rs b/src/error.rs index 8c46774e..2ad4f6b9 100644 --- a/src/error.rs +++ b/src/error.rs @@ -757,6 +757,48 @@ where 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(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(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(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(err: T) -> Error +where + T: Send + Sync + fmt::Debug + fmt::Display + 'static, +{ + InternalError::new(err, StatusCode::GATEWAY_TIMEOUT).into() +} + + #[cfg(test)] mod tests { use super::*;