Improve error message logging from electron (#7130)

This commit is contained in:
Zane
2026-02-12 08:59:02 -08:00
committed by GitHub
parent ac2a569868
commit 2303e46e8d
6 changed files with 29 additions and 26 deletions
+4 -4
View File
@@ -241,10 +241,10 @@ export function trackPageView(page: string, referrer?: string): void {
export function trackError(
errorType: string,
options: {
component?: string; // React component name
page?: string; // Current route/page
action?: string; // What user was doing
stackSummary?: string; // Use getStackSummary() to generate
component?: string;
page?: string;
action?: string;
stackSummary?: string;
recoverable?: boolean;
} = {}
): void {
+14
View File
@@ -22,6 +22,20 @@ export function errorMessage(err: Error | unknown, default_value?: string) {
}
}
export function formatErrorForLogging(error: unknown): string {
if (error instanceof Error) {
return `${error.name}: ${error.message}${error.stack ? `\n${error.stack}` : ''}`;
}
if (typeof error === 'object' && error !== null) {
try {
return JSON.stringify(error, null, 2);
} catch {
return String(error);
}
}
return String(error);
}
export async function compressImageDataUrl(dataUrl: string): Promise<string> {
return new Promise((resolve, reject) => {
const img = new globalThis.Image();