-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #885 from navikt/handtering-av-softerror
Håndtering av "soft errors":
- Loading branch information
Showing
8 changed files
with
131 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import GuiModelMetadata from "./GuiModelMetadata.ts"; | ||
|
||
export type GuiModel = { | ||
request?: any[]; | ||
response?: any[]; | ||
metadata?: string[]; | ||
metadata?: GuiModelMetadata; | ||
fromFile?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
interface GuiModelMetadata { | ||
status?: string, | ||
info?: string, | ||
bruktSats?: string, | ||
debugLog?: string, | ||
} | ||
|
||
export default GuiModelMetadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import {Alert, Button, CopyButton, Heading, Modal} from "@navikt/ds-react"; | ||
import React, {ErrorInfo, ReactNode, useRef} from "react"; | ||
import {LinkIcon, ThumbUpIcon} from "@navikt/aksel-icons"; | ||
|
||
|
||
interface FallbackProps { | ||
error: Error; | ||
errorInfo: ErrorInfo; | ||
} | ||
|
||
const ErrorFallback: React.FC<FallbackProps> = ({error}): ReactNode => { | ||
|
||
const ref = useRef<HTMLDialogElement>(null) | ||
const [windowSize] = React.useState([window.innerWidth, window.innerHeight]); | ||
|
||
const defaultErrorHeading = "Oops! En feil har oppstått 😵💫😵" | ||
|
||
if (error.toString().length > 150) { | ||
|
||
return ( | ||
<div> | ||
<Modal ref={ref} open={true} width={`${windowSize[0] - 100}`}> | ||
<Modal.Header> | ||
<Alert variant="error">{defaultErrorHeading}</Alert> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<details style={{whiteSpace: 'pre-wrap'}} open={true}> | ||
<summary>Detaljert feilmelding</summary> | ||
<br/> | ||
{error.toString()} | ||
</details> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<CopyButton className={"copyButton"} | ||
copyText={error.toString()} | ||
text="Kopier feilmelding" | ||
activeText="Kopierte feilmelding" | ||
icon={<LinkIcon aria-hidden/>} | ||
activeIcon={<ThumbUpIcon aria-hidden/>} | ||
/> | ||
<Button type="button" onClick={() => ref.current?.close()}> | ||
Lukk | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
</div> | ||
) | ||
} | ||
return ( | ||
<div> | ||
<Alert variant="error" style={{}}> | ||
<Heading spacing size={"small"} level={"3"}> | ||
{defaultErrorHeading} | ||
</Heading> | ||
{error.toString()} | ||
</Alert> | ||
</div> | ||
) | ||
} | ||
|
||
export default ErrorFallback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters