dioxus/examples/error_handle.rs
2024-01-16 13:18:46 -06:00

25 lines
414 B
Rust

use dioxus::{dioxus_core::CapturedError, prelude::*};
fn main() {
launch_desktop(app);
}
fn app() -> Element {
rsx! {
ErrorBoundary {
handle_error: |error: CapturedError| rsx! {"Found error {error}"},
DemoC { x: 1 }
}
}
}
#[component]
fn DemoC(x: i32) -> Element {
let result = Err("Error");
result.throw()?;
rsx! {
h1 { "{x}" }
}
}