diff --git a/src/app.rs b/src/app.rs
index 6df1766..dd0e0d2 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -6,6 +6,7 @@ use leptos_meta::*;
use leptos_router::*;
use crate::pages::login::*;
use crate::pages::signup::*;
+use crate::error_template::{AppError, ErrorTemplate};
#[component]
pub fn App() -> impl IntoView {
@@ -21,11 +22,17 @@ pub fn App() -> impl IntoView {
// content for this welcome page
-
+
+ }
+ .into_view()
+ }>
-
diff --git a/src/error_template.rs b/src/error_template.rs
new file mode 100644
index 0000000..b30718c
--- /dev/null
+++ b/src/error_template.rs
@@ -0,0 +1,73 @@
+use http::status::StatusCode;
+use leptos::*;
+use thiserror::Error;
+
+#[cfg(feature = "ssr")]
+use leptos_axum::ResponseOptions;
+
+#[derive(Clone, Debug, Error)]
+pub enum AppError {
+ #[error("Not Found")]
+ NotFound,
+}
+
+impl AppError {
+ pub fn status_code(&self) -> StatusCode {
+ match self {
+ AppError::NotFound => StatusCode::NOT_FOUND,
+ }
+ }
+}
+
+// A basic function to display errors served by the error boundaries.
+// Feel free to do more complicated things here than just displaying the error.
+#[component]
+pub fn ErrorTemplate(
+ #[prop(optional)] outside_errors: Option,
+ #[prop(optional)] errors: Option>,
+) -> impl IntoView {
+ let errors = match outside_errors {
+ Some(e) => create_rw_signal(e),
+ None => match errors {
+ Some(e) => e,
+ None => panic!("No Errors found and we expected errors!"),
+ },
+ };
+ // Get Errors from Signal
+ let errors = errors.get_untracked();
+
+ // Downcast lets us take a type that implements `std::error::Error`
+ let errors: Vec = errors
+ .into_iter()
+ .filter_map(|(_k, v)| v.downcast_ref::().cloned())
+ .collect();
+
+ // Only the response code for the first error is actually sent from the server
+ // this may be customized by the specific application
+ #[cfg(feature = "ssr")]
+ {
+ let response = use_context::();
+ if let Some(response) = response {
+ response.set_status(errors[0].status_code());
+ }
+ }
+
+ view! {
+ {if errors.len() > 1 {"Errors"} else {"Error"}}
+ {error_code.to_string()}
+ "Error: " {error_string}
+ }
+ }
+ />
+ }
+}
diff --git a/src/lib.rs b/src/lib.rs
index 28a9044..be30f52 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,6 +11,7 @@ pub mod pages;
pub mod users;
pub mod search;
pub mod fileserv;
+pub mod error_template;
use cfg_if::cfg_if;
cfg_if! {