agent-ecosystem/src/renderer/utils/unwrapIpc.ts
iliya 7c9631c1b9 feat: enhance README and UI for team management and review processes
- Added "Flexible autonomy" feature to README, allowing users to configure agent control levels.
- Updated task creation description for clarity in README.
- Improved team detail view messaging to better inform users about draft teams and provisioning status.
- Enhanced review function to prevent duplicate approval comments and events, ensuring idempotency.
- Expanded expected IPC signals to include 'TEAM_DRAFT' for better error handling.
2026-03-21 14:01:24 +02:00

31 lines
931 B
TypeScript

import { createLogger } from '@shared/utils/logger';
const logger = createLogger('Renderer:unwrapIpc');
export class IpcError extends Error {
constructor(
public readonly operation: string,
message: string,
public readonly causeError?: unknown
) {
super(message);
this.name = 'IpcError';
}
}
/** Error messages that represent expected transient states, not real failures. */
const EXPECTED_IPC_SIGNALS = ['TEAM_PROVISIONING', 'TEAM_DRAFT'];
export async function unwrapIpc<T>(operation: string, fn: () => Promise<T>): Promise<T> {
try {
return await fn();
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
if (EXPECTED_IPC_SIGNALS.some((sig) => message.includes(sig))) {
logger.debug(`[${operation}] ${message}`);
} else {
logger.error(`[${operation}] ${message}`);
}
throw new IpcError(operation, message, error);
}
}