Skip to content

Commit b118430

Browse files
authored
Merge pull request #1017 from joshunrau/error-report
2 parents a95f2b7 + f5184d2 commit b118430

File tree

9 files changed

+86
-34
lines changed

9 files changed

+86
-34
lines changed

apps/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@opendatacapture/schemas": "workspace:*",
4545
"@opendatacapture/subject-utils": "workspace:*",
4646
"@prisma/client": "catalog:",
47-
"axios": "^1.7.7",
47+
"axios": "catalog:",
4848
"express": "^4.19.2",
4949
"lodash-es": "workspace:lodash-es__4.x@*",
5050
"mongodb": "^6.8.1",

apps/gateway/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@opendatacapture/runtime-v1": "workspace:*",
2525
"@opendatacapture/schemas": "workspace:*",
2626
"@prisma/client": "catalog:",
27-
"axios": "^1.7.7",
27+
"axios": "catalog:",
2828
"compression": "^1.7.4",
2929
"express": "^4.19.2",
3030
"lodash-es": "workspace:lodash-es__4.x@*",

apps/playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@opendatacapture/runtime-core": "workspace:*",
2424
"@opendatacapture/runtime-v1": "workspace:*",
2525
"@opendatacapture/schemas": "workspace:*",
26-
"axios": "^1.7.7",
26+
"axios": "catalog:",
2727
"esbuild-wasm": "catalog:",
2828
"framer-motion": "^11.5.4",
2929
"immer": "^10.1.1",

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@opendatacapture/subject-utils": "workspace:*",
3636
"@tanstack/react-query": "^5.55.4",
3737
"@tanstack/react-query-devtools": "^5.55.4",
38-
"axios": "^1.7.7",
38+
"axios": "catalog:",
3939
"clsx": "^2.1.1",
4040
"framer-motion": "^11.5.4",
4141
"html2canvas": "^1.4.1",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "opendatacapture",
33
"type": "module",
4-
"version": "1.6.0",
4+
"version": "1.6.1",
55
"private": true,
66
"packageManager": "[email protected]",
77
"license": "Apache-2.0",

packages/react-core/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"storybook": "storybook dev -p 6006"
1515
},
1616
"peerDependencies": {
17+
"axios": "catalog:",
1718
"react": "workspace:react__18.x@*",
1819
"react-dom": "workspace:react-dom__18.x@*",
1920
"tailwindcss": "3.x",
@@ -24,7 +25,9 @@
2425
"@douglasneuroinformatics/libui": "catalog:",
2526
"@opendatacapture/runtime-core": "workspace:*",
2627
"framer-motion": "^11.5.4",
28+
"http-status-codes": "^2.3.0",
2729
"lucide-react": "^0.439.0",
30+
"serialize-error": "^11.0.3",
2831
"ts-pattern": "workspace:ts-pattern__5.x@*"
2932
},
3033
"devDependencies": {

packages/react-core/src/components/ErrorPage/ErrorPage.tsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,54 @@
11
import { useEffect } from 'react';
22

3+
import { Button } from '@douglasneuroinformatics/libui/components';
4+
import { useDownload } from '@douglasneuroinformatics/libui/hooks';
5+
import { isAxiosError } from 'axios';
6+
import { getReasonPhrase } from 'http-status-codes';
7+
import { serializeError } from 'serialize-error';
8+
39
export type ErrorPageProps = {
4-
error: {
5-
message: string;
6-
};
10+
error: unknown;
711
};
812

913
export const ErrorPage = ({ error }: ErrorPageProps) => {
14+
const download = useDownload();
15+
1016
useEffect(() => {
1117
console.error(error);
1218
}, [error]);
1319

20+
let heading = 'Unknown Error';
21+
if (isAxiosError(error) && error.status) {
22+
heading = `${error.status} - ${getReasonPhrase(error.status)}`;
23+
}
24+
1425
return (
1526
<div className="flex min-h-screen flex-col items-center justify-center gap-1 p-3 text-center">
16-
<h1 className="text-muted-foreground text-sm font-semibold uppercase tracking-wide">Unexpected Error</h1>
17-
<h3 className="text-3xl font-extrabold tracking-tight sm:text-4xl md:text-5xl">Something Went Wrong</h3>
27+
<h1 className="text-muted-foreground text-sm font-semibold uppercase tracking-wide">Something Went Wrong</h1>
28+
<h3 className="text-3xl font-extrabold tracking-tight sm:text-4xl md:text-5xl">{heading}</h3>
1829
<p className="text-muted-foreground mt-2 max-w-prose text-sm sm:text-base">
19-
We apologize for the inconvenience. Please contact us for further assistance.
30+
We apologize for the inconvenience. Please download the error report using the button below and send it to your
31+
platform administrator for further assistance.
2032
</p>
21-
<div className="mt-6">
22-
<button
23-
className="text-sky-800 underline-offset-4 hover:text-sky-700 hover:underline dark:text-sky-200 dark:hover:text-sky-300"
33+
<div className="mt-6 flex gap-2">
34+
<Button
35+
type="button"
36+
variant="outline"
37+
onClick={() => {
38+
void download('error.json', JSON.stringify(serializeError(error), null, 2));
39+
}}
40+
>
41+
Error Report
42+
</Button>
43+
<Button
2444
type="button"
45+
variant="primary"
2546
onClick={() => {
2647
window.location.assign(window.location.origin);
2748
}}
2849
>
29-
Reload Page<span aria-hidden="true"> &rarr;</span>
30-
</button>
50+
Reload Page
51+
</Button>
3152
</div>
3253
</div>
3354
);

pnpm-lock.yaml

Lines changed: 45 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ catalog:
1818
'@testing-library/jest-dom': ^6.5.0
1919
'@testing-library/react': ^16.0.1
2020
'@testing-library/user-event': ^14.5.2
21+
axios: '^1.7.7'
2122
esbuild: 0.23.x
2223
esbuild-wasm: 0.23.x
2324
happy-dom: ^15.7.4

0 commit comments

Comments
 (0)