Skip to content

Commit dd8b62c

Browse files
committed
chore: 🔨 replace .error with .log
1 parent d0d8e6b commit dd8b62c

File tree

10 files changed

+30
-23
lines changed

10 files changed

+30
-23
lines changed

src/app/[locale]/dashboard/error.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export default function Error({
1212
}) {
1313
useEffect(() => {
1414
// Log the error to an error reporting service
15-
console.error(error);
15+
console.log(error);
1616
}, [error]);
1717

1818
return (
1919
<div className="flex h-[calc(100vh-160px)] w-full flex-col items-center justify-center gap-y-4">
20-
<h2 className=" text-5xl font-bold text-destructive">
20+
<h2 className="text-5xl font-bold text-destructive">
2121
Oops, Something Went Wrong!
2222
</h2>
2323
<Button onClick={() => reset()}>Try Again</Button>

src/app/[locale]/dashboard/projects/[projectId]/delete-card.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { Button } from "~/components/ui/button";
1515
import { Card, CardDescription, CardTitle } from "~/components/ui/card";
1616
import { toast } from "~/hooks/use-toast";
17+
import { isRedirectError } from "~/lib/utils";
1718
import { deleteProjectById } from "../action";
1819

1920
export default function DeleteCard({ id }: { id: string }) {
@@ -27,12 +28,14 @@ export default function DeleteCard({ id }: { id: string }) {
2728
});
2829
})
2930
.catch((error) => {
30-
console.error(error);
31-
toast({
32-
title: "Error deleting project.",
33-
description: "Please try again.",
34-
variant: "destructive",
35-
});
31+
console.log(error);
32+
if (!isRedirectError(error)) {
33+
toast({
34+
title: "Error deleting project.",
35+
description: "Please try again.",
36+
variant: "destructive",
37+
});
38+
}
3639
})
3740
);
3841
};

src/app/[locale]/dashboard/projects/[projectId]/editable-details.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ import { toast } from "~/hooks/use-toast";
1818
import { updateProjectById } from "../action";
1919
import { projectSchema, type ProjectFormValues } from "../create-project-modal";
2020

21-
// const projectEditSchema = projectSchema.extend({
22-
// id: z.string().readonly(),
23-
// });
24-
25-
// type ProjectEditValues = z.infer<typeof projectEditSchema>;
26-
2721
export default function EditableDetails({
2822
initialValues,
2923
}: {
@@ -42,7 +36,7 @@ export default function EditableDetails({
4236
});
4337
form.reset();
4438
} catch (error) {
45-
console.error(error);
39+
console.log(error);
4640
toast({
4741
title: "Error creating project.",
4842
description: "Please try again.",

src/app/[locale]/dashboard/projects/create-project-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function CreateProjectModal() {
5858
form.reset();
5959
setIsOpen(false);
6060
} catch (error) {
61-
console.error({ error });
61+
console.log(error);
6262
if (error instanceof FreePlanLimitError) {
6363
return toast({
6464
title: "Free plan limit reached. Please upgrade your plan.",

src/app/[locale]/dashboard/settings/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function removeUserOldImageFromCDN(
2626
await utapi.deleteFiles(currentImageFileKey as string);
2727
}
2828
} catch (e) {
29-
console.error(e);
29+
console.log(e);
3030
const newImageFileKey = getImageKeyFromUrl(newImageUrl);
3131
await utapi.deleteFiles(newImageFileKey as string);
3232
}

src/app/[locale]/dashboard/settings/error.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export default function Error({
1212
}) {
1313
useEffect(() => {
1414
// Log the error to an error reporting service
15-
console.error(error);
15+
console.log(error);
1616
}, [error]);
1717

1818
return (
1919
<div className="flex h-full w-full flex-col items-center justify-center gap-y-4">
20-
<h2 className=" text-4xl font-bold text-destructive">
20+
<h2 className="text-4xl font-bold text-destructive">
2121
Something Went Wrong!
2222
</h2>
2323
<Button onClick={() => reset()}>Try Again</Button>

src/app/[locale]/dashboard/settings/settings-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default function SettingsForm({ currentUser }: { currentUser: User }) {
8585
try {
8686
await removeNewImageFromCDN(getValues().picture);
8787
} catch (error) {
88-
console.error(error);
88+
console.log(error);
8989
}
9090
}
9191
reset();

src/app/global-error.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export default function GlobalError({
1212
}) {
1313
useEffect(() => {
1414
// Log the error to an error reporting service
15-
console.error(error);
15+
console.log(error);
1616
}, [error]);
1717

1818
return (
1919
<div className="flex h-[calc(100vh-160px)] w-full flex-col items-center justify-center gap-y-4">
20-
<h2 className=" text-5xl font-bold text-destructive">
20+
<h2 className="text-5xl font-bold text-destructive">
2121
Oops, Something Went Wrong!
2222
</h2>
2323
<Button onClick={() => reset()}>Try Again</Button>

src/components/layout/image-upload-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default function ImageUploadModal({
4747
}
4848
},
4949
onUploadError: (e) => {
50-
console.error(e);
50+
console.log(e);
5151
toast({
5252
title: "Error occurred while uploading!",
5353
variant: "destructive",

src/lib/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,13 @@ export class FreePlanLimitError extends Error {
5353
super(message);
5454
}
5555
}
56+
57+
export function isRedirectError(error: unknown): boolean {
58+
return (
59+
error !== null &&
60+
typeof error === "object" &&
61+
"digest" in error &&
62+
typeof error.digest === "string" &&
63+
error.digest.includes("NEXT_REDIRECT")
64+
);
65+
}

0 commit comments

Comments
 (0)