This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
error pages #93
Merged
Merged
error pages #93
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
257eac3
initial draft for error pages
Matisse-Sulzer 51f8240
indentation fixed
Matisse-Sulzer 044f6d7
docs
Matisse-Sulzer 983c721
error pages v1
Matisse-Sulzer 5c51757
indentation fixed
Matisse-Sulzer 2e0f86e
layout adjusted, using RouterProvider instead of BrowserRouter to ren…
Matisse-Sulzer 3b7cb88
linter
Matisse-Sulzer 9a2b0a5
documentation
Matisse-Sulzer 20c0d8d
Merge branch 'development' into frontend/enhancement/error_pages
Matisse-Sulzer d8034f9
Merge branch 'development' of https://github.com/SELab-2/UGent-3 into…
Matisse-Sulzer a47932e
Merge branch 'frontend/enhancement/error_pages' of https://github.com…
Matisse-Sulzer 32e501e
linter error parameters
Matisse-Sulzer e1a9140
Merge branch 'development' into frontend/enhancement/error_pages
Matisse-Sulzer 0c632c0
Added i18n, changed general structure of App component and got rid of…
Matisse-Sulzer 8471fd6
Merge branch 'development' into frontend/enhancement/error_pages
Matisse-Sulzer 8d5178c
linting, package-lock.json fix
Matisse-Sulzer 246cec7
package file
Matisse-Sulzer 8baecd8
changes to paramters in ErrorPage.tsx
Matisse-Sulzer df75fd5
Merge branch 'development' into frontend/enhancement/error_pages
Matisse-Sulzer 28066ff
Merge branch 'development' into frontend/enhancement/error_pages
Matisse-Sulzer 04c19cb
use of keyPrefix
Matisse-Sulzer 775b6b4
Merge branch 'development' into frontend/enhancement/error_pages
Matisse-Sulzer 7a6c25c
Merge branch 'development' into frontend/enhancement/error_pages
Matisse-Sulzer 7634577
keyPrefix
Matisse-Sulzer 3cc8257
fix
Matisse-Sulzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
describe('Error page test', () => { | ||
it('Error page should load appropriately', () => { | ||
expect( | ||
() => { | ||
cy.request({ | ||
method: 'POST', | ||
path: '**', | ||
body: {name: "fail"}, | ||
failOnStatusCode: false | ||
}).then(response => { | ||
expect(response.status).to.be(404) // is supposed to be 404 | ||
}) | ||
} | ||
) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
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,15 @@ | ||
import { Outlet } from "react-router-dom"; | ||
import { Header } from "./components/Header/Header.tsx"; | ||
|
||
/** | ||
* Basic layout component that will be used on all routes. | ||
* @returns The Layout component | ||
*/ | ||
export function Layout(): JSX.Element { | ||
return ( | ||
<> | ||
<Header /> | ||
<Outlet /> | ||
</> | ||
); | ||
} |
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,32 @@ | ||
import { useRouteError, isRouteErrorResponse } from "react-router-dom"; | ||
import { ErrorPage } from "./ErrorPage.tsx"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
/** | ||
* This component will render the ErrorPage component with the appropriate data when an error occurs. | ||
* @returns The ErrorBoundary component | ||
*/ | ||
export function ErrorBoundary() { | ||
const error = useRouteError(); | ||
const { t } = useTranslation(); | ||
|
||
if (isRouteErrorResponse(error)) { | ||
if (error.status == 404) { | ||
return ( | ||
<ErrorPage statusCode={"404"} statusTitle={t("error.pageNotFound")} message={t("error.pageNotFoundMessage")} /> | ||
); | ||
} else if (error.status == 403) { | ||
return ( | ||
<ErrorPage statusCode={"403"} statusTitle={t("error.forbidden")} message={t("error.forbiddenMessage")} /> | ||
); | ||
} else if (error.status >= 400 && error.status <= 499) { | ||
return ( | ||
<ErrorPage statusCode={error.statusText} statusTitle={t("error.clientError")} message={t("error.clientErrorMessage")} /> | ||
); | ||
} else if (error.status >= 500 && error.status <= 599) { | ||
return ( | ||
<ErrorPage statusCode={error.statusText} statusTitle={t("error.serverError")} message={t("error.serverErrorMessage")} /> | ||
); | ||
} | ||
} | ||
} |
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,51 @@ | ||
import { Grid, Typography } from "@mui/material"; | ||
|
||
/** | ||
* This component will be rendered when an error occurs. | ||
* @param statusCode - The status code of the error | ||
* @param statusTitle - The name of the error | ||
* @param message - Additional information about the error | ||
* @returns The ErrorPage component | ||
*/ | ||
export function ErrorPage( | ||
{ statusCode, statusTitle, message }: { statusCode: string, statusTitle: string, message: string } | ||
): React.JSX.Element { | ||
return ( | ||
<Grid | ||
container | ||
justifyContent="center" | ||
alignItems="center" | ||
direction="column" | ||
sx={{ minHeight: "100vh" }} | ||
spacing={2} | ||
> | ||
<Grid item> | ||
<Grid | ||
container | ||
justifyContent="center" | ||
alignItems="center" | ||
spacing={4} | ||
> | ||
<Grid item> | ||
<Typography variant="h1"> | ||
{ statusCode } | ||
</Typography> | ||
</Grid> | ||
<Grid item> | ||
<img src="/img/error_pigeon.png" height="150vh" alt="icon" /> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
<Grid item> | ||
<Typography variant="h3"> | ||
{ statusTitle } | ||
</Typography> | ||
</Grid> | ||
<Grid item> | ||
<Typography variant="body1"> | ||
{ message } | ||
</Typography> | ||
</Grid> | ||
</Grid> | ||
); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
keyPrefix
instead of doingerror.
everywhereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3cc8257