Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions site/src/components/ErrorSummary/ErrorSummary.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { action } from "@storybook/addon-actions"
import { ComponentMeta, Story } from "@storybook/react"
import React from "react"
import { ErrorSummary, ErrorSummaryProps } from "./ErrorSummary"
Expand All @@ -14,4 +15,12 @@ WithError.args = {
error: new Error("Something went wrong!"),
}

export const WithRetry = Template.bind({})
WithRetry.args = {
error: new Error("Failed to fetch something!"),
retry: () => {
action("retry")
},
}

export const WithUndefined = Template.bind({})
27 changes: 18 additions & 9 deletions site/src/components/ErrorSummary/ErrorSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import Button from "@material-ui/core/Button"
import RefreshIcon from "@material-ui/icons/Refresh"
import React from "react"
import { Stack } from "../Stack/Stack"

const Language = {
unknownErrorMessage: "Unknown error",
retryMessage: "Retry",
unknownErrorMessage: "An unknown error has occurred",
}

export interface ErrorSummaryProps {
error: Error | unknown
retry?: () => void
}

export const ErrorSummary: React.FC<ErrorSummaryProps> = ({ error }) => {
// TODO: More interesting error page
export const ErrorSummary: React.FC<ErrorSummaryProps> = ({ error, retry }) => (
<Stack>
{!(error instanceof Error) ? <div>{Language.unknownErrorMessage}</div> : <div>{error.toString()}</div>}

if (!(error instanceof Error)) {
return <div>{Language.unknownErrorMessage}</div>
} else {
return <div>{error.toString()}</div>
}
}
{retry && (
<div>
<Button onClick={retry} startIcon={<RefreshIcon />} variant="outlined">
{Language.retryMessage}
</Button>
</div>
)}
</Stack>
)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy