mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-06 05:40:02 -06:00
Co-authored-by: Harsh Bhat <90265455+harshsbhat@users.noreply.github.com> Co-authored-by: Johannes <johannes@formbricks.com> Co-authored-by: Piyush Gupta <56182734+gupta-piyush19@users.noreply.github.com> Co-authored-by: Aditya <162564995+Naidu-4444@users.noreply.github.com> Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com> Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com> Co-authored-by: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com> Co-authored-by: Jakob Schott <154420406+jakobsitory@users.noreply.github.com> Co-authored-by: Suraj <surajsuthar0067@gmail.com> Co-authored-by: Kshitij Sharma <63995641+kshitij-codes@users.noreply.github.com> Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com> Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
// Error components must be Client components
|
|
import { Button } from "@/modules/ui/components/button";
|
|
import { ErrorComponent } from "@/modules/ui/components/error-component";
|
|
import * as Sentry from "@sentry/nextjs";
|
|
import { useTranslate } from "@tolgee/react";
|
|
import { getClientErrorData } from "@formbricks/types/errors";
|
|
|
|
const ErrorBoundary = ({ error, reset }: { error: Error; reset: () => void }) => {
|
|
const { t } = useTranslate();
|
|
const errorData = getClientErrorData(error);
|
|
|
|
if (process.env.NODE_ENV === "development") {
|
|
console.error(error.message);
|
|
} else {
|
|
Sentry.captureException(error);
|
|
}
|
|
|
|
return (
|
|
<div className="flex h-full w-full flex-col items-center justify-center">
|
|
<ErrorComponent title={errorData.title} description={errorData.description} />
|
|
{errorData.showButtons && (
|
|
<div className="mt-2">
|
|
<Button variant="secondary" onClick={() => reset()} className="mr-2">
|
|
{t("common.try_again")}
|
|
</Button>
|
|
<Button onClick={() => (window.location.href = "/")}>{t("common.go_to_dashboard")}</Button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default ErrorBoundary;
|