aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index c38b2eb..25bc21f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,7 +12,6 @@ use std::rc::Rc;
use std::{collections::HashSet, time::Duration};
use poem::http::StatusCode;
-use poem::Response;
use poem::{
endpoint::EmbeddedFilesEndpoint,
get, handler,
@@ -21,6 +20,7 @@ use poem::{
web::{Data, Path, Query},
EndpointExt, Route, Server,
};
+use poem::{IntoResponse, Response};
use rust_embed::RustEmbed;
use error::BlossomError;
@@ -114,6 +114,14 @@ async fn plants() -> Result<()> {
Err(BlossomError::Unimplemented)
}
+async fn custom_error(err: poem::Error) -> impl IntoResponse {
+ templates::Error {
+ status: err.status(),
+ message: err.to_string(),
+ }
+ .with_status(err.status())
+}
+
#[tokio::main]
async fn main() -> std::result::Result<(), std::io::Error> {
// let mut skinny_data = mastodon_async::Data::default();
@@ -126,6 +134,7 @@ async fn main() -> std::result::Result<(), std::io::Error> {
.at("/contact", get(contact))
.at("/plants", get(plants))
.nest("/static/", EmbeddedFilesEndpoint::<Static>::new())
+ .catch_all_error(custom_error)
.with(AddData::new(
reqwest::Client::builder()
.connect_timeout(Duration::from_secs(1))