change to new error response functions

master
rasul 5 years ago
parent 2410896899
commit 59c3e91f6c

@ -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<HandlerFuture> {
),
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)
}
};

@ -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<HandlerFuture> {
),
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)
}
};

@ -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<HandlerFuture> {
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)
}
};

@ -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<HandlerFuture> {
@ -40,9 +40,8 @@ pub fn put(mut state: State) -> Box<HandlerFuture> {
),
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<HandlerFuture> {
}
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<HandlerFuture> {
}
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<HandlerFuture> {
.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<HandlerFuture> {
}
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<HandlerFuture> {
}
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)
}
};

@ -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<HandlerFuture> {
),
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)
}
};

Loading…
Cancel
Save