From 59c3e91f6cb0ef7e341b7ad9abcf31aff2b10996 Mon Sep 17 00:00:00 2001 From: rasul Date: Sun, 2 Feb 2020 16:39:33 -0600 Subject: [PATCH] change to new error response functions --- src/routes/edit.rs | 6 +++--- src/routes/index.rs | 4 ++-- src/routes/raw.rs | 4 ++-- src/routes/submit.rs | 16 +++++++--------- src/routes/view.rs | 6 +++--- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/routes/edit.rs b/src/routes/edit.rs index 27e2abd..0ca8f5d 100644 --- a/src/routes/edit.rs +++ b/src/routes/edit.rs @@ -12,7 +12,7 @@ use mime; use serde_derive::Deserialize; use crate::config::Config; -use crate::html_error::create_error_response; +use crate::error_response::create_html_error_response; use crate::paste::Paste; use crate::syntax::SYNTAXES; @@ -60,13 +60,13 @@ pub fn route(mut state: State) -> Box { ), Err(e) => { error!("edit.rs(10): {:?}", e); - create_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) + create_html_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) } } } Err(e) => { error!("edit.rs(20): {:?}", e); - create_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) + create_html_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) } }; diff --git a/src/routes/index.rs b/src/routes/index.rs index 0648f15..369c338 100644 --- a/src/routes/index.rs +++ b/src/routes/index.rs @@ -10,7 +10,7 @@ use log::error; use mime; use crate::config::Config; -use crate::html_error::create_error_response; +use crate::error_response::create_html_error_response; use crate::syntax::SYNTAXES; #[derive(Debug, Template)] @@ -38,7 +38,7 @@ pub fn route(mut state: State) -> Box { ), Err(e) => { error!("index.rs: {:?}", e); - create_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) + create_html_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) } }; diff --git a/src/routes/raw.rs b/src/routes/raw.rs index 9ec95f4..9ab2a6a 100644 --- a/src/routes/raw.rs +++ b/src/routes/raw.rs @@ -11,7 +11,7 @@ use mime; use serde_derive::Deserialize; use crate::config::Config; -use crate::html_error::create_error_response; +use crate::error_response::create_text_error_response; use crate::paste::Paste; #[derive(Deserialize, StateData, StaticResponseExtender)] @@ -31,7 +31,7 @@ pub fn get(mut state: State) -> Box { Ok(paste) => create_response(&state, StatusCode::OK, mime::TEXT_PLAIN, paste.text), Err(e) => { error!("raw.rs: {:?}", e); - create_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) + create_text_error_response(StatusCode::INTERNAL_SERVER_ERROR, &state) } }; diff --git a/src/routes/submit.rs b/src/routes/submit.rs index 48c7667..d8670b4 100644 --- a/src/routes/submit.rs +++ b/src/routes/submit.rs @@ -13,7 +13,7 @@ use mime; use url::form_urlencoded; use crate::config::Config; -use crate::html_error::create_error_response; +use crate::error_response::{create_html_error_response, create_text_error_response}; use crate::paste::Paste; pub fn put(mut state: State) -> Box { @@ -40,9 +40,8 @@ pub fn put(mut state: State) -> Box { ), Err(e) => { error!("submit.rs(10): {:?}", e); - create_error_response( + create_text_error_response( StatusCode::INTERNAL_SERVER_ERROR, - config.url, &state, ) } @@ -50,9 +49,8 @@ pub fn put(mut state: State) -> Box { } Err(e) => { error!("submit.rs(20): {:?}", e); - create_error_response( + create_text_error_response( StatusCode::INTERNAL_SERVER_ERROR, - config.url, &state, ) } @@ -60,7 +58,7 @@ pub fn put(mut state: State) -> Box { } Err(e) => { error!("submit.rs(30): {:?}", e); - create_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) + create_text_error_response(StatusCode::INTERNAL_SERVER_ERROR, &state) } }; @@ -95,7 +93,7 @@ pub fn post(mut state: State) -> Box { .unwrap(), Err(e) => { error!("submit.rs(40): {:?}", e); - create_error_response( + create_html_error_response( StatusCode::INTERNAL_SERVER_ERROR, config.url, &state, @@ -105,7 +103,7 @@ pub fn post(mut state: State) -> Box { } Err(e) => { error!("submit.rs(50): {:?}", e); - create_error_response( + create_html_error_response( StatusCode::INTERNAL_SERVER_ERROR, config.url, &state, @@ -115,7 +113,7 @@ pub fn post(mut state: State) -> Box { } Err(e) => { error!("submit.rs(60): {:?}", e); - create_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) + create_html_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) } }; diff --git a/src/routes/view.rs b/src/routes/view.rs index 779c0aa..96e48ab 100644 --- a/src/routes/view.rs +++ b/src/routes/view.rs @@ -14,7 +14,7 @@ use serde_derive::Deserialize; use syntect::html::ClassedHTMLGenerator; use crate::config::Config; -use crate::html_error::create_error_response; +use crate::error_response::create_html_error_response; use crate::paste::Paste; use crate::syntax::SYNTAX_SET; @@ -75,13 +75,13 @@ pub fn get(mut state: State) -> Box { ), Err(e) => { error!("view.rs(10): {:?}", e); - create_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) + create_html_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) } } } Err(e) => { error!("view.rs(20): {:?}", e); - create_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) + create_html_error_response(StatusCode::INTERNAL_SERVER_ERROR, config.url, &state) } };