Skip to content

Commit

Permalink
fix(error-bounbdary): adapting to typescript 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
eikeland committed Dec 2, 2024
1 parent 6a7691b commit 6113677
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions packages/errorboundary/src/legacy/Fallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Styled = {
};

export type FallbackProps = {
readonly error: unknown;
readonly error: Error;
readonly errorType?: ErrorType;
readonly message?: React.ReactNode;
readonly resourceName?: string;
Expand Down Expand Up @@ -64,29 +64,27 @@ export const Fallback = (props: FallbackProps): JSX.Element => {
}, [resetBoundary, onTakeAction]);
return (
<Styled.root>
<>
{props.icon ?? <FallbackIcon errorType={errorType} />}
<Typography variant="h3">{title ?? generateTitle(errorType, resourceName)}</Typography>
<Typography variant="ingress" token={{ color: tokens.colors.text.static_icons__tertiary.hex }}>
{message ?? (error as Error).message}
</Typography>
{props.icon ?? <FallbackIcon errorType={errorType} />}
<Typography variant="h3">{title ?? generateTitle(errorType, resourceName)}</Typography>
<Typography variant="ingress" token={{ color: tokens.colors.text.static_icons__tertiary.hex }}>
{message ?? error.message}
</Typography>

{action && (
<Button variant="outlined" onClick={onClick}>
{action}
</Button>
)}
{error && (
<Accordion headerLevel="h5" chevronPosition="right" style={{ width: '100%' }}>
<Accordion.Item>
<Accordion.Header style={{ height: 'auto' }}>Error details</Accordion.Header>
<Accordion.Panel>
<Styled.stacktrace>{(error as Error).stack}</Styled.stacktrace>
</Accordion.Panel>
</Accordion.Item>
</Accordion>
)}
</>
{action && (
<Button variant="outlined" onClick={onClick}>
{action}
</Button>
)}
{error && (
<Accordion headerLevel="h5" chevronPosition="right" style={{ width: '100%' }}>
<Accordion.Item>
<Accordion.Header style={{ height: 'auto' }}>Error details</Accordion.Header>
<Accordion.Panel>
<Styled.stacktrace>{error.stack}</Styled.stacktrace>
</Accordion.Panel>
</Accordion.Item>
</Accordion>
)}
</Styled.root>
);
};

0 comments on commit 6113677

Please sign in to comment.