Improve error message logging from electron (#7130)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user