Skip to content

Commit

Permalink
Adjust archive error
Browse files Browse the repository at this point in the history
  • Loading branch information
elie222 committed Dec 30, 2024
1 parent cae4c21 commit 64cb6e8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apps/web/utils/actions/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { withActionInstrumentation } from "@/utils/actions/middleware";
import { isActionError } from "@/utils/error";

// do not return functions to the client or we'll get an error
const isStatusOk = (status?: number) => status && status >= 200 && status < 300;
const isStatusOk = (status: number) => status >= 200 && status < 300;

export const archiveThreadAction = withActionInstrumentation(
"archiveThread",
Expand All @@ -39,7 +39,7 @@ export const archiveThreadAction = withActionInstrumentation(
labelId,
});

if (!isStatusOk(res?.status)) return { error: "Failed to archive thread" };
if (!isStatusOk(res.status)) return { error: "Failed to archive thread" };
},
);

Expand Down
2 changes: 1 addition & 1 deletion apps/web/utils/gmail/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export async function archiveThread({
const error = archiveResult.reason as Error;
if (error.message?.includes("Requested entity was not found")) {
console.error(`Thread not found: ${threadId}`);
return null;
return { status: 404, message: "Thread not found" };
}
console.error(`Failed to archive thread: ${threadId}`, error);
throw error;
Expand Down

1 comment on commit 64cb6e8

@vercel
Copy link

@vercel vercel bot commented on 64cb6e8 Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.