diff --git a/src/components/bookmarks/group.jsx b/src/components/bookmarks/group.jsx
index af510081..d4c05663 100644
--- a/src/components/bookmarks/group.jsx
+++ b/src/components/bookmarks/group.jsx
@@ -1,10 +1,11 @@
+import ErrorBoundary from "components/errorboundry";
import List from "components/bookmarks/list";
export default function BookmarksGroup({ group }) {
return (
{group.name}
-
+
);
}
diff --git a/src/components/errorboundry.jsx b/src/components/errorboundry.jsx
new file mode 100644
index 00000000..ffee89ff
--- /dev/null
+++ b/src/components/errorboundry.jsx
@@ -0,0 +1,41 @@
+import React from 'react';
+
+export default class ErrorBoundary extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = { error: null, errorInfo: null };
+ }
+
+ componentDidCatch(error, errorInfo) {
+ // Catch errors in any components below and re-render with error message
+ this.setState({
+ error,
+ errorInfo
+ })
+
+ // You can also log error messages to an error reporting service here
+ // eslint-disable-next-line no-console
+ console.error(error, errorInfo);
+ }
+
+ render() {
+ const { error, errorInfo } = this.state;
+ if (errorInfo) {
+ // Error path
+ return (
+
+
Something went wrong.
+
+ {error && error.toString()}
+
+ {errorInfo.componentStack}
+
+
+ );
+ }
+
+ // Normally, just render children
+ const { children } = this.props;
+ return children;
+ }
+}
\ No newline at end of file
diff --git a/src/components/services/group.jsx b/src/components/services/group.jsx
index daae1909..373023c1 100644
--- a/src/components/services/group.jsx
+++ b/src/components/services/group.jsx
@@ -1,5 +1,6 @@
import classNames from "classnames";
+import ErrorBoundary from "components/errorboundry";
import List from "components/services/list";
export default function ServicesGroup({ services, layout }) {
@@ -12,7 +13,7 @@ export default function ServicesGroup({ services, layout }) {
)}
>
{services.name}
-
+
);
}
diff --git a/src/components/services/list.jsx b/src/components/services/list.jsx
index 80b45592..a42a64a1 100644
--- a/src/components/services/list.jsx
+++ b/src/components/services/list.jsx
@@ -1,5 +1,6 @@
import classNames from "classnames";
+import ErrorBoundary from "components/errorboundry";
import Item from "components/services/item";
const columnMap = [
@@ -23,7 +24,7 @@ export default function List({ services, layout }) {
)}
>
{services.map((service) => (
-
+
))}
);
diff --git a/src/pages/index.jsx b/src/pages/index.jsx
index 2a1c6e7d..c9661a07 100644
--- a/src/pages/index.jsx
+++ b/src/pages/index.jsx
@@ -8,6 +8,7 @@ import { useEffect, useContext, useState } from "react";
import { BiError } from "react-icons/bi";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
+import ErrorBoundary from "components/errorboundry";
import ServicesGroup from "components/services/group";
import BookmarksGroup from "components/bookmarks/group";
import Widget from "components/widgets/widget";
@@ -191,14 +192,14 @@ function Home({ initialSettings }) {
{widgets
.filter((widget) => !rightAlignedWidgets.includes(widget.type))
.map((widget, i) => (
-
+
))}
{widgets
.filter((widget) => rightAlignedWidgets.includes(widget.type))
.map((widget, i) => (
-
+
))}
>
@@ -208,7 +209,7 @@ function Home({ initialSettings }) {
{services && (
{services.map((group) => (
-
+
))}
)}
@@ -216,7 +217,7 @@ function Home({ initialSettings }) {
{bookmarks && (
{bookmarks.map((group) => (
-
+
))}
)}