From 98ef0b44ecd6a2e8ac44aade0061379f543671b8 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Wed, 4 Jan 2023 22:38:27 -0800 Subject: [PATCH] Add error boundaries to individual routes --- .../components/error-fallback.tsx | 24 +++++++++++++++---- src/renderer/router/app-router.tsx | 10 ++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/renderer/features/action-required/components/error-fallback.tsx b/src/renderer/features/action-required/components/error-fallback.tsx index 1bdbee04..4f01fd99 100644 --- a/src/renderer/features/action-required/components/error-fallback.tsx +++ b/src/renderer/features/action-required/components/error-fallback.tsx @@ -1,15 +1,18 @@ import { Box, Center, Divider, Group, Stack } from '@mantine/core'; import type { FallbackProps } from 'react-error-boundary'; -import { RiErrorWarningLine, RiArrowLeftLine } from 'react-icons/ri'; +import { RiErrorWarningLine, RiHomeFill, RiArrowLeftSLine } from 'react-icons/ri'; import { useNavigate, useRouteError } from 'react-router'; import styled from 'styled-components'; import { Button, Text } from '/@/renderer/components'; +import { AppRoute } from '/@/renderer/router/routes'; const Container = styled(Box)` background: var(--main-bg); `; -export const ErrorFallback = ({ error, resetErrorBoundary }: FallbackProps) => { +export const ErrorFallback = ({ resetErrorBoundary }: FallbackProps) => { + const error = useRouteError() as any; + return (
@@ -47,11 +50,22 @@ export const RouteErrorBoundary = () => { navigate(-1); }; + const handleHome = () => { + navigate(AppRoute.HOME); + }; + return (
+ { {error?.message}