4bad1324b9
Move some code out to other files. Add transaction guard
41 lines
1.0 KiB
Rust
41 lines
1.0 KiB
Rust
use std::collections::HashMap;
|
|
|
|
use rocket::serde::json::json;
|
|
use rocket_dyn_templates::Template;
|
|
|
|
use crate::JsonValue;
|
|
|
|
#[catch(403)]
|
|
pub(crate) async fn forbidden() -> Template {
|
|
let map: HashMap<String, String> = HashMap::new();
|
|
Template::render("errors/403", &map)
|
|
}
|
|
|
|
#[catch(500)]
|
|
pub(crate) async fn internal_server_error() -> Template {
|
|
let map: HashMap<String, String> = HashMap::new();
|
|
Template::render("errors/500", &map)
|
|
}
|
|
|
|
#[catch(401)]
|
|
pub(crate) async fn not_authorized() -> Template {
|
|
let map: HashMap<String, String> = HashMap::new();
|
|
Template::render("errors/401", &map)
|
|
}
|
|
|
|
#[catch(404)]
|
|
pub(crate) async fn not_found() -> Template {
|
|
let map: HashMap<String, String> = HashMap::new();
|
|
Template::render("errors/404", &map)
|
|
}
|
|
|
|
#[catch(413)]
|
|
pub(crate) async fn payload_too_large() -> JsonValue {
|
|
json!({"error": "Data too large.", "errors": ["Data too large."]})
|
|
}
|
|
|
|
#[catch(422)]
|
|
pub(crate) async fn unprocessable_entity() -> JsonValue {
|
|
json!({"error": "Invalid request.", "errors": ["Invalid request."]})
|
|
}
|