1
0

error_boundary.rs 579 B

1234567891011121314151617181920212223242526272829303132
  1. #![allow(non_snake_case)]
  2. use dioxus::prelude::*;
  3. #[test]
  4. fn catches_panic() {
  5. let mut dom = VirtualDom::new(app);
  6. _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations);
  7. }
  8. fn app(cx: Scope) -> Element {
  9. render! {
  10. div {
  11. h1 { "Title" }
  12. NoneChild {}
  13. ThrowChild {}
  14. }
  15. }
  16. }
  17. fn NoneChild(_cx: Scope) -> Element {
  18. None
  19. }
  20. fn ThrowChild(cx: Scope) -> Element {
  21. Err(std::io::Error::new(std::io::ErrorKind::AddrInUse, "asd")).throw()?;
  22. let _g: i32 = "123123".parse().throw()?;
  23. render! { div {} }
  24. }