-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
702b158
commit a2239fd
Showing
6 changed files
with
75 additions
and
14 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
apps/web-remix/app/components/errorBoundaries/ErrorBoundaryLayout.tsx
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,33 @@ | ||
import React, { PropsWithChildren } from "react"; | ||
import { | ||
isRouteErrorResponse, | ||
Links, | ||
Meta, | ||
Scripts, | ||
useRouteError, | ||
} from "@remix-run/react"; | ||
|
||
export const ErrorBoundaryLayout: React.FC< | ||
PropsWithChildren<{ className?: string }> | ||
> = ({ children, className }) => { | ||
const error = useRouteError(); | ||
const getTitle = () => { | ||
if (isRouteErrorResponse(error)) { | ||
if (error.status === 404) return "Not Found"; | ||
return "Something went wrong"; | ||
} | ||
}; | ||
return ( | ||
<html> | ||
<head> | ||
<title>{getTitle()}</title> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body className={className}> | ||
{children} | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
}; |
30 changes: 30 additions & 0 deletions
30
apps/web-remix/app/components/pages/pipelines/build/errorBoundary.tsx
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,30 @@ | ||
import React from "react"; | ||
import { isRouteErrorResponse, useRouteError } from "@remix-run/react"; | ||
|
||
export const BuildErrorBoundary = () => { | ||
const error = useRouteError(); | ||
|
||
const getStatus = () => { | ||
if (isRouteErrorResponse(error)) { | ||
return error.status; | ||
} | ||
|
||
return 500; | ||
}; | ||
|
||
const status = getStatus(); | ||
|
||
return ( | ||
<div className="my-6 p-2 rounded-lg text-center"> | ||
{status === 404 ? <NotFound /> : <Runtime />} | ||
</div> | ||
); | ||
}; | ||
|
||
function NotFound() { | ||
return <p className="text-white text-sm">Page not found...</p>; | ||
} | ||
|
||
function Runtime() { | ||
return <p className="text-red-500 text-sm">Ups! Something went wrong...</p>; | ||
} |
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 +1,2 @@ | ||
export { PipelineBuilder as page, meta } from "./page"; | ||
export { BuildErrorBoundary as ErrorBoundary } from "./errorBoundary"; |
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
6 changes: 5 additions & 1 deletion
6
apps/web-remix/app/routes/_dashboard.$organizationId.pipelines_.$pipelineId.build.tsx
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