Files
ccs/src/errors/index.ts
T
kaitranntt 22dbfd91c5 refactor(errors): centralize error handling infrastructure
- add errors/ directory with error types, handler, cleanup registry

- extract claude-spawner.ts from auth modules

- update imports across auth, ccs, web-server

Phase 2 & 4: Error handling consolidation
2025-12-19 11:47:43 -05:00

64 lines
1.3 KiB
TypeScript

/**
* CCS Error Handling Module
*
* Centralized error handling system for CCS CLI providing:
* - Standardized exit codes
* - Custom error types with exit code mapping
* - Centralized error handler with cleanup
* - Cleanup callback registry
*
* @example
* ```typescript
* import { handleError, ConfigError, ExitCode, registerCleanup } from './errors';
*
* // Register cleanup for spawned process
* registerCleanup(() => proxy.kill());
*
* // Throw typed error
* throw new ConfigError('Invalid config file', '~/.ccs/config.json');
*
* // Or handle directly
* handleError(new NetworkError('Connection refused'));
* ```
*/
// Exit codes
export { ExitCode, EXIT_CODE_DESCRIPTIONS, isSuccess, isRecoverable } from './exit-codes';
// Error types
export {
CCSError,
ConfigError,
NetworkError,
AuthError,
BinaryError,
ProviderError,
ProfileError,
ProxyError,
MigrationError,
UserAbortError,
isCCSError,
isRecoverableError,
} from './error-types';
// Error handler
export {
handleError,
exitWithError,
exitWithSuccess,
withErrorHandling,
assertOrExit,
} from './error-handler';
// Cleanup registry
export {
registerCleanup,
runCleanup,
clearCleanup,
getCleanupCount,
hasCleanupRun,
createCleanupScope,
} from './cleanup-registry';
export type { CleanupCallback } from './cleanup-registry';