default_errors.rs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. use crate::{components::Link, hooks::use_route};
  2. use dioxus::prelude::*;
  3. use dioxus_router_core::prelude::{named, FailureExternalNavigation as FENName, RootIndex};
  4. #[allow(non_snake_case)]
  5. pub fn FailureExternalNavigation(cx: Scope) -> Element {
  6. let state = use_route(&cx).expect(
  7. "`FailureExternalNavigation` can only be mounted by the router itself, \
  8. since it is not exposed",
  9. );
  10. let href = state.parameter::<FENName>().expect(
  11. "`FailureExternalNavigation` cannot be mounted without receiving its parameter, \
  12. since it is not exposed",
  13. );
  14. render! {
  15. h1 { "External Navigation Failure!" }
  16. p {
  17. "The application tried to programmatically navigate to an external page. This "
  18. "operation has failed. Click the link below to complete the navigation manually."
  19. }
  20. a {
  21. href: "{href}",
  22. rel: "noopener noreferrer",
  23. "Click here to fix the failure."
  24. }
  25. }
  26. }
  27. #[allow(non_snake_case)]
  28. pub fn FailureNamedNavigation(cx: Scope) -> Element {
  29. render! {
  30. h1 { "Named Navigation Failure!" }
  31. p {
  32. "The application has tried to navigate to an unknown name. This is a bug. Please "
  33. "inform the developer, so they can fix it."
  34. b { "Thank you!" }
  35. }
  36. p {
  37. "We are sorry for the inconvenience. The link below may help to fix the problem, but "
  38. "there is no guarantee."
  39. }
  40. Link {
  41. target: named::<RootIndex>(),
  42. "Click here to try to fix the failure."
  43. }
  44. }
  45. }
  46. #[allow(non_snake_case)]
  47. pub fn FailureRedirectionLimit(cx: Scope) -> Element {
  48. render! {
  49. h1 { "Redirection Limit Failure!" }
  50. p {
  51. "The application seems to have entered into an endless redirection loop. This is a "
  52. "bug. Please inform the developer, so they can fix it."
  53. b { "Thank you!" }
  54. }
  55. p {
  56. "We are sorry for the inconvenience. The link below may help to fix the problem, but "
  57. "there is no guarantee."
  58. }
  59. Link {
  60. target: named::<RootIndex>(),
  61. "Click here to try to fix the failure."
  62. }
  63. }
  64. }