diff options
Diffstat (limited to 'thallium-frontend/src/pages/ErrorPage.tsx')
| -rw-r--r-- | thallium-frontend/src/pages/ErrorPage.tsx | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/thallium-frontend/src/pages/ErrorPage.tsx b/thallium-frontend/src/pages/ErrorPage.tsx index a649e25..ffc6f8a 100644 --- a/thallium-frontend/src/pages/ErrorPage.tsx +++ b/thallium-frontend/src/pages/ErrorPage.tsx @@ -1,18 +1,28 @@ -import { useRouteError } from 'react-router-dom'; +import { useRouteError, isRouteErrorResponse } from 'react-router-dom'; import Card from '../components/Card'; const LandingPage = () => { - const error: any = useRouteError() || {}; + const error = useRouteError(); - let title, message, isUnexpected = false; + let title = 'Unexpected Error', message, isUnexpected = false; - if (error.status === 404) { - title = 'Not Found'; - message = 'The requested page could not be found.'; + if (isRouteErrorResponse(error)) { + if (error.status === 404) { + title = 'Not Found'; + message = 'The requested page could not be found.'; + } else { + message = error.statusText; + } + } else if (error instanceof Error) { + message = error.message; + isUnexpected = true; + } else if (typeof error === 'string') { + message = error; + isUnexpected = true; } else { - title = 'Error'; - message = error.message || error.statusText; + console.error(error); + message = 'Unknown error'; isUnexpected = true; } |