error_handle.rs 418 B

12345678910111213141516171819202122232425
  1. use dioxus::{core::CapturedError, prelude::*};
  2. fn main() {
  3. dioxus_desktop::launch(app);
  4. }
  5. fn app() -> Element {
  6. rsx! {
  7. ErrorBoundary {
  8. handle_error: |error: CapturedError| rsx! {"Found error {error}"},
  9. DemoC { x: 1 }
  10. }
  11. }
  12. }
  13. #[component]
  14. fn DemoC(x: i32) -> Element {
  15. let result = Err("Error");
  16. result.throw()?;
  17. render! {
  18. h1 { "{x}" }
  19. }
  20. }