default_errors.rs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. use crate::{
  2. components::GenericLink, hooks::use_generic_route, navigation::NavigationTarget,
  3. routable::Routable,
  4. };
  5. use dioxus::prelude::*;
  6. #[allow(non_snake_case)]
  7. pub fn FailureExternalNavigation<R: Routable + Clone>(cx: Scope) -> Element {
  8. let href = use_generic_route::<R>(cx).expect(
  9. "`FailureExternalNavigation` can only be mounted by the router itself, \
  10. since it is not exposed",
  11. );
  12. render! {
  13. h1 { "External Navigation Failure!" }
  14. p {
  15. "The application tried to programmatically navigate to an external page. This "
  16. "operation has failed. Click the link below to complete the navigation manually."
  17. }
  18. a {
  19. href: "{href}",
  20. rel: "noopener noreferrer",
  21. "Click here to fix the failure."
  22. }
  23. }
  24. }
  25. #[allow(non_snake_case)]
  26. pub fn FailureNamedNavigation<R: Routable + Clone>(cx: Scope) -> Element {
  27. render! {
  28. h1 { "Named Navigation Failure!" }
  29. p {
  30. "The application has tried to navigate to an unknown name. This is a bug. Please "
  31. "inform the developer, so they can fix it."
  32. b { "Thank you!" }
  33. }
  34. p {
  35. "We are sorry for the inconvenience. The link below may help to fix the problem, but "
  36. "there is no guarantee."
  37. }
  38. GenericLink::<R> {
  39. target: NavigationTarget::Internal(R::from_str("/").unwrap_or_else(|_| {
  40. panic!("Failed to parse `/` as a Route")
  41. })),
  42. "Click here to try to fix the failure."
  43. }
  44. }
  45. }
  46. #[allow(non_snake_case)]
  47. pub fn FailureRedirectionLimit<R: Routable + Clone>(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. GenericLink::<R> {
  60. target: NavigationTarget::Internal(R::from_str("/").unwrap_or_else(|_| {
  61. panic!("Failed to parse `/` as a Route")
  62. })),
  63. "Click here to try to fix the failure."
  64. }
  65. }
  66. }