Plume/src/routes/errors.rs

23 lines
569 B
Rust
Raw Normal View History

2018-06-18 17:59:49 +02:00
use rocket_contrib::Template;
2018-06-21 11:58:54 +02:00
use rocket::Request;
use rocket::request::FromRequest;
use models::users::User;
2018-06-18 17:59:49 +02:00
#[catch(404)]
2018-06-21 11:58:54 +02:00
fn not_found(req: &Request) -> Template {
let user = User::from_request(req).succeeded();
2018-06-18 17:59:49 +02:00
Template::render("errors/404", json!({
2018-06-21 11:58:54 +02:00
"error_message": "Page not found",
"account": user
2018-06-18 17:59:49 +02:00
}))
}
#[catch(500)]
2018-06-21 11:58:54 +02:00
fn server_error(req: &Request) -> Template {
let user = User::from_request(req).succeeded();
2018-06-18 17:59:49 +02:00
Template::render("errors/500", json!({
2018-06-21 11:58:54 +02:00
"error_message": "Server error",
"account": user
2018-06-18 17:59:49 +02:00
}))
}