diff --git a/app/components/error-boundary.tsx b/app/components/error-boundary.tsx index 2771da6..b6c55a0 100644 --- a/app/components/error-boundary.tsx +++ b/app/components/error-boundary.tsx @@ -4,7 +4,7 @@ import { captureRemixErrorBoundaryError } from '@sentry/remix' export function GeneralErrorBoundary({ specialCases, }: { - specialCases?: { [key: number]: string } + specialCases?: { [key: number]: string | JSX.Element } }) { const error = useRouteError() console.error(error) @@ -12,16 +12,25 @@ export function GeneralErrorBoundary({ const isResponse = isRouteErrorResponse(error) let errorMessage = 'Something went wrong. Please, try again later.' const isClientError = isResponse && error.status >= 400 && error.status < 500 + const specialCase = isClientError ? specialCases?.[error.status] : undefined if (isResponse && isClientError) { - if (specialCases?.[error.status]) { - errorMessage = specialCases[error.status] + if (typeof specialCase === 'string') { + errorMessage = specialCase } else { errorMessage = error.statusText } } + let children: undefined | string | JSX.Element + if (typeof specialCase !== 'undefined' && typeof specialCase !== 'string') { + children = specialCase + } else { + children = isClientError + ? `${error.status} - ${errorMessage}` + : errorMessage + } return (