place error boundaries closer to the source

This commit is contained in:
Ben Phelps 2022-10-05 13:43:22 +03:00
parent 88c774339d
commit ea96999377
6 changed files with 31 additions and 21 deletions

View file

@ -1,6 +1,5 @@
import classNames from "classnames";
import ErrorBoundary from "components/errorboundry";
import List from "components/services/list";
export default function ServicesGroup({ services, layout }) {
@ -13,7 +12,7 @@ export default function ServicesGroup({ services, layout }) {
)}
>
<h2 className="text-theme-800 dark:text-theme-300 text-xl font-medium">{services.name}</h2>
<ErrorBoundary><List services={services.services} layout={layout} /></ErrorBoundary>
<List services={services.services} layout={layout} />
</div>
);
}

View file

@ -1,6 +1,5 @@
import classNames from "classnames";
import ErrorBoundary from "components/errorboundry";
import Item from "components/services/item";
const columnMap = [
@ -24,7 +23,7 @@ export default function List({ services, layout }) {
)}
>
{services.map((service) => (
<ErrorBoundary key={service.name}><Item key={service.name} service={service} /></ErrorBoundary>
<Item key={service.name} service={service} />
))}
</ul>
);

View file

@ -1,5 +1,6 @@
import { useTranslation } from "next-i18next";
import ErrorBoundary from "components/errorboundry";
import components from "widgets/components";
export default function Widget({ service }) {
@ -8,7 +9,11 @@ export default function Widget({ service }) {
const ServiceWidget = components[service.widget.type];
if (ServiceWidget) {
return <ServiceWidget service={service} />;
return (
<ErrorBoundary>
<ServiceWidget service={service} />
</ErrorBoundary>
);
}
return (