mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 20:17:45 +00:00
- 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
64 lines
1.3 KiB
TypeScript
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';
|