Skip to content

Commit 577e479

Browse files
authored
fix: better map error boundary (#271)
Closes #267
1 parent cb7c89b commit 577e479

File tree

1 file changed

+37
-17
lines changed

1 file changed

+37
-17
lines changed

src/app.tsx

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { Alert, Box, FileUpload } from "@chakra-ui/react";
1+
import {
2+
AbsoluteCenter,
3+
Alert,
4+
Box,
5+
Center,
6+
FileUpload,
7+
HStack,
8+
Link,
9+
Stack,
10+
Text,
11+
} from "@chakra-ui/react";
212
import { useDuckDb } from "duckdb-wasm-kit";
313
import { useEffect } from "react";
414
import { ErrorBoundary } from "react-error-boundary";
15+
import { LuGithub } from "react-icons/lu";
516
import Footer from "./components/footer";
617
import Map from "./components/map";
718
import Overlay from "./components/overlay";
@@ -12,22 +23,31 @@ import { uploadFile } from "./utils/upload";
1223
function MapFallback({ error }: { error: unknown }) {
1324
const message = error instanceof Error ? error.message : String(error);
1425
return (
15-
<Box
16-
h="100%"
17-
w="100%"
18-
display="flex"
19-
alignItems="center"
20-
justifyContent="center"
21-
bg="gray.100"
22-
>
23-
<Alert.Root status="error">
24-
<Alert.Indicator />
25-
<Alert.Content>
26-
<Alert.Title>Map failed to load</Alert.Title>
27-
<Alert.Description>{message}</Alert.Description>
28-
</Alert.Content>
29-
</Alert.Root>
30-
</Box>
26+
<AbsoluteCenter h="100dvh%" w="100dvw">
27+
<Center maxW={"40%"}>
28+
<Alert.Root status="error">
29+
<Alert.Indicator />
30+
<Alert.Content gap={4}>
31+
<Alert.Title>
32+
<HStack>We're really sorry!</HStack>
33+
</Alert.Title>
34+
<Alert.Description>
35+
<Stack>
36+
<HStack>Something went wrong in the map component</HStack>
37+
<Text>The error message is "{message}"</Text>
38+
<Text>
39+
Please{" "}
40+
<Link href="https://github.com/developmentseed/stac-map/issues/new?template=bug_report.md">
41+
open an issue <LuGithub />
42+
</Link>{" "}
43+
so we can fix it!
44+
</Text>
45+
</Stack>
46+
</Alert.Description>
47+
</Alert.Content>
48+
</Alert.Root>
49+
</Center>
50+
</AbsoluteCenter>
3151
);
3252
}
3353

0 commit comments

Comments
 (0)