Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/utils/gmail/draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function deleteDraft(gmail: gmail_v1.Gmail, draftId: string) {
}
logger.info("Successfully deleted draft", { draftId });
} catch (error) {
if (error instanceof Error && "code" in error && error.code === 404) {
if (isNotFoundError(error)) {
logger.warn("Draft not found or already deleted, skipping deletion.", {
draftId,
});
Expand Down
32 changes: 21 additions & 11 deletions apps/web/utils/outlook/draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ export async function getDraft({
return message;
} catch (error) {
if (isNotFoundError(error)) {
return null;
}

// Handle Outlook's "object not found in the store" error
if (
error instanceof Error &&
error.message.includes("not found in the store")
) {
logger.info("Draft not found, returning null.", { draftId });
return null;
}

Expand Down Expand Up @@ -67,11 +60,28 @@ export async function deleteDraft({
}

function isNotFoundError(error: unknown): boolean {
const err = error as { statusCode?: number; code?: number | string };
return (
const err = error as {
statusCode?: number;
code?: number | string;
message?: string;
};

// Check error code
if (
err?.statusCode === 404 ||
err?.code === 404 ||
err?.code === "ErrorItemNotFound" ||
err?.code === "itemNotFound"
);
) {
return true;
}

if (
err?.message?.includes("not found in the store") ||
err?.message?.includes("ErrorItemNotFound")
) {
return true;
}

return false;
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.24.6
v2.24.7
Loading