dioxus/examples/error_handle.rs
2023-11-07 18:24:07 -06:00

30 lines
518 B
Rust

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