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
1 change: 0 additions & 1 deletion apps/web/app/api/user/stats/newsletters/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ async function getNewsletterCounts(
} catch (error) {
logger.error("getNewsletterCounts error", {
error,
errorMessage: error instanceof Error ? error.message : String(error),
errorStack: error instanceof Error ? error.stack : undefined,
});
return [];
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/watch/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function watchEmails({
logger.warn("Auth failure while watching inbox - cleaning up tokens", {
emailAccountId,
providerName: provider.name,
error: errorMessage,
error,
});
await cleanupInvalidTokens({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cleanupInvalidTokens(...) is awaited inside the catch. If it throws, watchEmails rejects instead of returning { success: false, error }. Consider wrapping it in its own try/catch (and log) so the function preserves its return contract.

-      await cleanupInvalidTokens({
-        emailAccountId,
-        reason: isInvalidGrant ? "invalid_grant" : "insufficient_permissions",
-        logger,
-      });
+      try {
+        await cleanupInvalidTokens({
+          emailAccountId,
+          reason: isInvalidGrant ? "invalid_grant" : "insufficient_permissions",
+          logger,
+        });
+      } catch (cleanupError) {
+        logger.error("Failed to cleanup invalid tokens", {
+          emailAccountId,
+          providerName: provider.name,
+          error: cleanupError,
+        });
+        captureException(cleanupError);
+      }

🚀 Reply to ask Macroscope to explain or update this suggestion.

👍 Helpful? React to give us feedback.

emailAccountId,
Expand Down
4 changes: 2 additions & 2 deletions apps/web/utils/actions/ai-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export const saveRulesPromptAction = actionClient
} else {
logger.error("Failed to create rule", {
ruleName: rule.name,
error: error instanceof Error ? error.message : String(error),
error,
});
}
}
Expand Down Expand Up @@ -500,7 +500,7 @@ export const createRulesAction = actionClient
error instanceof Error ? error.message : String(error);
logger.error("Failed to create rule", {
ruleName: rule.name,
error: errorMessage,
error,
});
errors.push({
ruleName: rule.name,
Expand Down
10 changes: 3 additions & 7 deletions apps/web/utils/actions/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async function fetchGmailLabels(
} catch (error) {
logger.warn("Failed to get details for label", {
labelName: label.name,
error: error instanceof Error ? error.message : String(error),
error,
});
return {
...label,
Expand All @@ -216,9 +216,7 @@ async function fetchGmailLabels(

return sortedLabels;
} catch (error) {
logger.warn("Failed to fetch Gmail labels", {
error: error instanceof Error ? error.message : String(error),
});
logger.warn("Failed to fetch Gmail labels", { error });
return [];
}
}
Expand All @@ -234,9 +232,7 @@ async function fetchGmailSignature(

return defaultSignature?.signature || "";
} catch (error) {
logger.warn("Failed to fetch Gmail signature", {
error: error instanceof Error ? error.message : String(error),
});
logger.warn("Failed to fetch Gmail signature", { error });
return "";
}
}
2 changes: 1 addition & 1 deletion apps/web/utils/ai/assistant/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const createRuleTool = ({
} catch (error) {
const message = error instanceof Error ? error.message : String(error);

logger.error("Failed to create rule", { error: message });
logger.error("Failed to create rule", { error });

return { error: "Failed to create rule", message };
}
Expand Down
6 changes: 3 additions & 3 deletions apps/web/utils/ai/assistant/process-user-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ ${stringifyEmailSimple(getEmailForLLM(originalEmail))}
logger.error("Error while updating rule", {
ruleName,
keys: Object.keys(rule),
error: message,
error,
});

return {
Expand Down Expand Up @@ -274,7 +274,7 @@ ${stringifyEmailSimple(getEmailForLLM(originalEmail))}
// groupId,
// type: groupItemType,
// value,
// error: message,
// error,
// });
// return {
// error: "Failed to add pattern",
Expand Down Expand Up @@ -339,7 +339,7 @@ ${stringifyEmailSimple(getEmailForLLM(originalEmail))}
groupItemId: groupItem.id,
type: groupItemType,
value,
error: message,
error,
});

return {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/utils/ai/mcp/mcp-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export async function createMcpToolsForAgent(
});
} catch (error) {
logger.error("Failed to create MCP client for integration", {
error: error instanceof Error ? error.message : String(error),
error,
integration: integration.name,
});
// Continue with other integrations
Expand Down
8 changes: 2 additions & 6 deletions apps/web/utils/ai/report/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,13 @@ export async function fetchEmailTemplates(

if (templates.length >= 10) break;
} catch (error) {
logger.warn("Failed to process draft:", {
error: error instanceof Error ? error.message : String(error),
});
logger.warn("Failed to process draft:", { error });
}
}

return templates;
} catch (error) {
logger.warn("Failed to fetch email templates:", {
error: error instanceof Error ? error.message : String(error),
});
logger.warn("Failed to fetch email templates:", { error });
return [];
}
}
2 changes: 1 addition & 1 deletion apps/web/utils/email/microsoft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ export class OutlookProvider implements EmailProvider {
return [];
} catch (error) {
this.logger.error("Failed to extract signature from sent emails", {
error: error instanceof Error ? error.message : String(error),
error,
});
return [];
}
Expand Down
4 changes: 1 addition & 3 deletions apps/web/utils/gmail/signature-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ export async function getGmailSignatures(

return signatures;
} catch (error) {
logger.error("Failed to fetch Gmail signatures", {
error: error instanceof Error ? error.message : String(error),
});
logger.error("Failed to fetch Gmail signatures", { error });
throw error;
}
}
2 changes: 1 addition & 1 deletion apps/web/utils/outlook/subscription-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class OutlookSubscriptionManager {
"Failed to cancel existing subscription (may already be expired)",
{
existingSubscriptionId,
error: error instanceof Error ? error.message : String(error),
error,
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/utils/user/merge-premium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export async function transferPremiumDuringMerge({
logger.error("Failed to transfer premium during user merge", {
sourceUserId,
targetUserId,
error: error instanceof Error ? error.message : String(error),
error,
});
// Don't rethrow - we want the merge to continue even if premium transfer fails
}
Expand Down
4 changes: 1 addition & 3 deletions apps/web/utils/webhook/process-history-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ export async function processHistoryItem(
}
}

logger.error("Error processing message", {
error: error instanceof Error ? error.message : String(error),
});
logger.error("Error processing message", { error });
throw error;
}
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.21.48
v2.21.49
Loading