diff --git a/leptos/src/error_boundary.rs b/leptos/src/error_boundary.rs index 4c187a708..c5a682f90 100644 --- a/leptos/src/error_boundary.rs +++ b/leptos/src/error_boundary.rs @@ -48,6 +48,28 @@ use leptos_reactive::{provide_context, run_as_child, signal_prelude::*}; /// {move || { /// /* etc. */ /// ``` +/// +/// ## Beginner's Tip: ErrorBoundary Requires Your Error To Implement std::error::Error. +/// `ErrorBoundary` requires your `Result` to implement [IntoView](https://docs.rs/leptos/latest/leptos/trait.IntoView.html). +/// `Result` only implements `IntoView` if `E` implements [std::error::Error](https://doc.rust-lang.org/std/error/trait.Error.html). +/// So, for instance, if you pass a `Result` where `T` implements [IntoView](https://docs.rs/leptos/latest/leptos/trait.IntoView.html) +/// and attempt to render the error for the purposes of `ErrorBoundary` you'll get a compiler error like this. +/// +/// ```rust,ignore +/// error[E0599]: the method `into_view` exists for enum `Result`, but its trait bounds were not satisfied +/// --> src/login.rs:229:32 +/// | +/// 229 | err => err.into_view(), +/// | ^^^^^^^^^ method cannot be called on `Result` due to unsatisfied trait bounds +/// | +/// = note: the following trait bounds were not satisfied: +/// `<&Result as FnOnce<()>>::Output = _` +/// which is required by `&Result: leptos::IntoView` +/// ... more notes here ... +/// ``` +/// +/// For more information about how to easily implement `Error` see +/// [thiserror](https://docs.rs/thiserror/latest/thiserror/) #[component] pub fn ErrorBoundary( /// The components inside the tag which will get rendered