agent-ecosystem/src/main/ipc/ipcWrapper.ts
iliya e005671123 feat: add Sentry error tracking and update docs
- 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
2026-03-22 17:03:15 +02:00

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 };
}
};
}