diff --git a/examples/islands/src/error_template.rs b/examples/islands/src/error_template.rs deleted file mode 100644 index d82dcec64..000000000 --- a/examples/islands/src/error_template.rs +++ /dev/null @@ -1,47 +0,0 @@ -use crate::errors::TodoAppError; -use leptos::prelude::*; -#[cfg(feature = "ssr")] -use leptos_axum::ResponseOptions; - -// A basic function to display errors served by the error boundaries. Feel free to do more complicated things -// here than just displaying them -#[component] -pub fn ErrorTemplate( - #[prop(optional)] outside_errors: Option, - #[prop(optional, into)] errors: Option>, -) -> impl IntoView { - let errors = match outside_errors { - Some(e) => RwSignal::new(e), - None => match errors { - Some(e) => e, - None => panic!("No Errors found and we expected errors!"), - }, - }; - - // Get Errors from Signal - // Downcast lets us take a type that implements `std::error::Error` - let errors = - move || errors.get().into_iter().map(|(_, v)| v).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! { -

"Errors"

- {move || { - errors() - .into_iter() - .map(|error| { - view! {

"Error: " {error.to_string()}

} - }) - .collect::>() - }} - } -} diff --git a/examples/islands/src/errors.rs b/examples/islands/src/errors.rs deleted file mode 100644 index 1f1aea92f..000000000 --- a/examples/islands/src/errors.rs +++ /dev/null @@ -1,21 +0,0 @@ -use http::status::StatusCode; -use thiserror::Error; - -#[derive(Debug, Clone, Error)] -pub enum TodoAppError { - #[error("Not Found")] - NotFound, - #[error("Internal Server Error")] - InternalServerError, -} - -impl TodoAppError { - pub fn status_code(&self) -> StatusCode { - match self { - TodoAppError::NotFound => StatusCode::NOT_FOUND, - TodoAppError::InternalServerError => { - StatusCode::INTERNAL_SERVER_ERROR - } - } - } -} diff --git a/examples/islands/src/fallback.rs b/examples/islands/src/fallback.rs index f074b524d..24d74fb0f 100644 --- a/examples/islands/src/fallback.rs +++ b/examples/islands/src/fallback.rs @@ -1,4 +1,4 @@ -use crate::{app::shell, error_template::ErrorTemplate, errors::TodoAppError}; +use crate::app::shell; use axum::{ body::Body, extract::State, @@ -20,8 +20,6 @@ pub async fn file_and_error_handler( if res.status() == StatusCode::OK { res.into_response() } else { - let mut errors = Errors::default(); - errors.insert_with_default_key(TodoAppError::NotFound); let handler = leptos_axum::render_app_to_stream(move || shell(&options)); handler(req).await.into_response() diff --git a/examples/islands/src/lib.rs b/examples/islands/src/lib.rs index 9d510a1f2..2c642d345 100644 --- a/examples/islands/src/lib.rs +++ b/examples/islands/src/lib.rs @@ -1,29 +1,10 @@ pub mod app; -pub mod error_template; -pub mod errors; #[cfg(feature = "ssr")] pub mod fallback; #[cfg(feature = "hydrate")] #[wasm_bindgen::prelude::wasm_bindgen] pub fn hydrate() { - use crate::app::App; - /* use tracing_subscriber::fmt; - use tracing_subscriber_wasm::MakeConsoleWriter; - - fmt() - .with_writer( - // To avoide trace events in the browser from showing their - // JS backtrace, which is very annoying, in my opinion - MakeConsoleWriter::default() - .map_trace_level_to(tracing::Level::DEBUG), - ) - // For some reason, if we don't do this in the browser, we get - // a runtime error. - .without_time() - .init(); - _ = console_log::init_with_level(log::Level::Error);*/ console_error_panic_hook::set_once(); - leptos::mount::hydrate_islands(); } diff --git a/examples/islands/src/main.rs b/examples/islands/src/main.rs index 2ff70f2eb..d793afb3a 100644 --- a/examples/islands/src/main.rs +++ b/examples/islands/src/main.rs @@ -1,12 +1,5 @@ use crate::{app::*, fallback::file_and_error_handler}; -use axum::{ - body::Body, - extract::{Path, State}, - http::Request, - response::{IntoResponse, Response}, - routing::get, - Router, -}; +use axum::Router; use leptos::prelude::*; use leptos_axum::{generate_route_list, LeptosRoutes}; use todo_app_sqlite_axum::*;