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
27 changes: 0 additions & 27 deletions apps/web/utils/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,6 @@ export function isError(value: any): value is ErrorMessage | ZodError {
return value?.error;
}

export function isErrorMessage(value: any): value is ErrorMessage {
return typeof value?.error === "string";
}

export function formatZodError(error: z.ZodError): string {
const formattedError = error.issues
.map((err) => `${err.path.join(".")}: ${err.message}`)
.join(", ");
return `Invalid data: ${formattedError}`;
}

export function formatGmailError(error: unknown): string {
return (error as any)?.errors?.[0]?.message ?? "Unknown error";
}

export function isGmailError(
error: unknown,
): error is { code: number; errors: { message: string }[] } {
Expand All @@ -48,18 +33,6 @@ export function isGmailError(
);
}

export function formatError(error: unknown): string {
if (isGmailError(error)) {
return formatGmailError(error);
} else if (error instanceof Error) {
// Use the standard message for Error instances
return error.message;
} else {
// Fallback for other types
return String(error);
}
}

export function captureException(
error: unknown,
additionalInfo?: { extra?: Record<string, any> },
Expand Down
7 changes: 2 additions & 5 deletions apps/web/utils/reply-tracker/draft-tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ActionType } from "@prisma/client";
import type { ParsedMessage } from "@/utils/types";
import prisma from "@/utils/prisma";
import { calculateSimilarity } from "@/utils/similarity-score";
import { formatError } from "@/utils/error";
import type { EmailProvider } from "@/utils/email/types";
import type { Logger } from "@/utils/logger";

Expand Down Expand Up @@ -219,15 +218,13 @@ export async function cleanupThreadAIDrafts({
} catch (error) {
logger.error("Error checking draft for cleanup", {
...actionLoggerOptions,
error: formatError(error),
error,
});
}
}

logger.info("Completed cleanup of old AI drafts for thread");
} catch (error) {
logger.error("Error during thread draft cleanup", {
error: formatError(error),
});
logger.error("Error during thread draft cleanup", { error });
}
}
15 changes: 4 additions & 11 deletions apps/web/utils/reply-tracker/handle-outbound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { EmailProvider } from "@/utils/email/types";
import { createScopedLogger } from "@/utils/logger";
import { handleOutboundReply } from "./outbound";
import { trackSentDraftStatus, cleanupThreadAIDrafts } from "./draft-tracking";
import { formatError } from "@/utils/error";

export async function handleOutboundMessage({
emailAccount,
Expand All @@ -30,18 +29,14 @@ export async function handleOutboundMessage({
provider,
logger,
}).catch((error) => {
logger.error("Error tracking sent draft status", {
error: formatError(error),
});
logger.error("Error tracking sent draft status", { error });
}),
handleOutboundReply({
emailAccount,
message,
provider,
}).catch((error) => {
logger.error("Error handling outbound reply", {
error: formatError(error),
});
logger.error("Error handling outbound reply", { error });
}),
]);

Expand All @@ -52,9 +47,7 @@ export async function handleOutboundMessage({
provider,
logger,
});
} catch (cleanupError) {
logger.error("Error during thread draft cleanup", {
error: cleanupError,
});
} catch (error) {
logger.error("Error during thread draft cleanup", { error });
}
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.18.21
v2.18.22
Loading