page errors

This commit is contained in:
Aravinth Manivannan 2021-10-13 14:03:26 +05:30
parent ec8aaee213
commit a287f2d31c
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88

View file

@ -187,70 +187,70 @@ impl From<MailboxError> for ServiceError {
#[cfg(not(tarpaulin_include))] #[cfg(not(tarpaulin_include))]
pub type ServiceResult<V> = std::result::Result<V, ServiceError>; pub type ServiceResult<V> = std::result::Result<V, ServiceError>;
//#[derive(Debug, Display, PartialEq, Error)] #[derive(Debug, Display, PartialEq, Error)]
//#[cfg(not(tarpaulin_include))] #[cfg(not(tarpaulin_include))]
//pub enum PageError { pub enum PageError {
// #[display(fmt = "Something weng wrong: Internal server error")] #[display(fmt = "Something weng wrong: Internal server error")]
// InternalServerError, InternalServerError,
//
// #[display(fmt = "{}", _0)] #[display(fmt = "{}", _0)]
// ServiceError(ServiceError), ServiceError(ServiceError),
//} }
//
//#[cfg(not(tarpaulin_include))] #[cfg(not(tarpaulin_include))]
//impl From<sqlx::Error> for PageError { impl From<sqlx::Error> for PageError {
// #[cfg(not(tarpaulin_include))] #[cfg(not(tarpaulin_include))]
// fn from(_: sqlx::Error) -> Self { fn from(_: sqlx::Error) -> Self {
// PageError::InternalServerError PageError::InternalServerError
// } }
//} }
//
//#[cfg(not(tarpaulin_include))] #[cfg(not(tarpaulin_include))]
//impl From<ServiceError> for PageError { impl From<ServiceError> for PageError {
// #[cfg(not(tarpaulin_include))] #[cfg(not(tarpaulin_include))]
// fn from(e: ServiceError) -> Self { fn from(e: ServiceError) -> Self {
// PageError::ServiceError(e) PageError::ServiceError(e)
// } }
//} }
//
//impl ResponseError for PageError { impl ResponseError for PageError {
// fn error_response(&self) -> HttpResponse { fn error_response(&self) -> HttpResponse {
// use crate::PAGES; use crate::PAGES;
// match self.status_code() { match self.status_code() {
// StatusCode::INTERNAL_SERVER_ERROR => HttpResponse::Found() StatusCode::INTERNAL_SERVER_ERROR => HttpResponse::Found()
// .append_header((header::LOCATION, PAGES.errors.internal_server_error)) .append_header((header::LOCATION, PAGES.errors.internal_server_error))
// .finish(), .finish(),
// _ => HttpResponse::Found() _ => HttpResponse::Found()
// .append_header((header::LOCATION, PAGES.errors.unknown_error)) .append_header((header::LOCATION, PAGES.errors.unknown_error))
// .finish(), .finish(),
// } }
// } }
//
// #[cfg(not(tarpaulin_include))] #[cfg(not(tarpaulin_include))]
// fn status_code(&self) -> StatusCode { fn status_code(&self) -> StatusCode {
// match self { match self {
// PageError::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR, PageError::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR,
// PageError::ServiceError(e) => e.status_code(), PageError::ServiceError(e) => e.status_code(),
// } }
// } }
//} }
//
//#[cfg(not(tarpaulin_include))] #[cfg(not(tarpaulin_include))]
//pub type PageResult<V> = std::result::Result<V, PageError>; pub type PageResult<V> = std::result::Result<V, PageError>;
//
//#[cfg(test)] #[cfg(test)]
//mod tests { mod tests {
// use super::*; use super::*;
// use crate::PAGES; use crate::PAGES;
//
// #[test] #[test]
// fn error_works() { fn error_works() {
// let resp: HttpResponse = PageError::InternalServerError.error_response(); let resp: HttpResponse = PageError::InternalServerError.error_response();
// assert_eq!(resp.status(), StatusCode::FOUND); assert_eq!(resp.status(), StatusCode::FOUND);
// let headers = resp.headers(); let headers = resp.headers();
// assert_eq!( assert_eq!(
// headers.get(header::LOCATION).unwrap(), headers.get(header::LOCATION).unwrap(),
// PAGES.errors.internal_server_error PAGES.errors.internal_server_error
// ); );
// } }
//} }