-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: 35C4n0r <[email protected]> Co-authored-by: Tal <[email protected]>
- Loading branch information
Showing
6 changed files
with
45 additions
and
83 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,36 +1,59 @@ | ||
// The error.js file convention allows you to gracefully handle unexpected runtime errors. | ||
// The way it does this is by automatically wrap a route segment and its nested children in a React Error Boundary. | ||
// https://nextjs.org/docs/app/api-reference/file-conventions/error | ||
// https://nextjs.org/docs/app/building-your-application/routing/error-handling#how-errorjs-works | ||
|
||
"use client"; | ||
import Image from "next/image"; | ||
import "./error.css"; | ||
|
||
// Custom Error Component | ||
import {useEffect} from "react"; | ||
import {Button, Text} from "@tremor/react"; | ||
export default function ErrorComponent({ | ||
errorMessage, | ||
url, | ||
error, | ||
reset, | ||
}: { | ||
errorMessage: String; | ||
url: String; | ||
error: Error | KeepApiError | ||
reset: () => void | ||
}) { | ||
useEffect(() => { | ||
console.error(error) | ||
}, [error]) | ||
|
||
return ( | ||
<div className="error-container"> | ||
<div className="error-message">{errorMessage}</div> | ||
{url && ( | ||
<div className="error-url"> | ||
Failed to query {url}, is Keep API up? | ||
</div> | ||
)} | ||
<div className="error-message">{error.toString()}</div> | ||
<div className={"error-url"}>ERROR_TYPE: {error.name}</div> | ||
{error instanceof KeepApiError && error.proposedResolution && (<div className="error-url"> | ||
{error.proposedResolution} | ||
</div>) | ||
} | ||
|
||
<div className="error-image"> | ||
<Image src="/keep.svg" alt="Keep" width={150} height={150} /> | ||
</div> | ||
<Button | ||
onClick={() => { | ||
console.log("Refreshing...") | ||
window.location.reload(); | ||
}} | ||
color="orange" | ||
variant="secondary" | ||
className="mt-4 border border-orange-500 text-orange-500"> | ||
<Text>Try Again!</Text> | ||
</Button> | ||
</div> | ||
); | ||
) | ||
} | ||
|
||
// Custom Error Class | ||
export class KeepApiError extends Error { | ||
url: string; | ||
proposedResolution: string; | ||
|
||
constructor(message: string, url: string) { | ||
constructor(message: string, url: string, proposedResolution: string) { | ||
super(message); | ||
this.name = "KeepApiError"; | ||
this.url = url; | ||
this.proposedResolution = proposedResolution; | ||
} | ||
} |
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