- Integrate @sentry/electron and @sentry/react for crash reporting - Add Sentry Vite plugin for source maps - Add error tracking to main process, renderer, and IPC layer - Exclude source maps from packaged builds - Update README with new screenshots - Add Sentry opt-out toggle in settings - Update release workflow with Sentry config
27 lines
932 B
TypeScript
27 lines
932 B
TypeScript
/**
|
|
* Generic IPC handler wrapper — standardizes error handling and logging.
|
|
*
|
|
* Creates a domain-specific wrapper that catches errors, logs them,
|
|
* and returns IpcResult<T> for consistent renderer-side handling.
|
|
*/
|
|
|
|
import { addMainBreadcrumb } from '@main/sentry';
|
|
import { createLogger } from '@shared/utils/logger';
|
|
|
|
import type { IpcResult } from '@shared/types/ipc';
|
|
|
|
export function createIpcWrapper(logPrefix: string) {
|
|
const log = createLogger(logPrefix);
|
|
|
|
return async function wrap<T>(operation: string, fn: () => Promise<T>): Promise<IpcResult<T>> {
|
|
addMainBreadcrumb('ipc', `${logPrefix}:${operation}`);
|
|
try {
|
|
const data = await fn();
|
|
return { success: true, data };
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error);
|
|
log.error(`handler error [${operation}]:`, message);
|
|
return { success: false, error: message };
|
|
}
|
|
};
|
|
}
|