- 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.
31 lines
931 B
TypeScript
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);
|
|
}
|
|
}
|