mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-02 08:19:59 +00:00
fix: wrap RecoveryManager in try-catch to prevent blocking CLI commands
Recovery failures (permission errors, disk full) no longer block --version/--help commands. Recovery is best-effort - warns on failure but allows basic CLI functionality to continue. Fixes edge case identified in PR #215 code review.
This commit is contained in:
+12
-6
@@ -294,13 +294,19 @@ async function main(): Promise<void> {
|
|||||||
// Auto-recovery for missing configuration (BEFORE any early-exit commands)
|
// Auto-recovery for missing configuration (BEFORE any early-exit commands)
|
||||||
// This ensures ALL commands benefit from auto-recovery, not just profile-switching flow
|
// This ensures ALL commands benefit from auto-recovery, not just profile-switching flow
|
||||||
// Recovery is safe to run early - it only creates missing files with safe defaults
|
// Recovery is safe to run early - it only creates missing files with safe defaults
|
||||||
const RecoveryManagerModule = await import('./management/recovery-manager');
|
// Wrapped in try-catch to prevent blocking --version/--help on permission errors
|
||||||
const RecoveryManager = RecoveryManagerModule.default;
|
try {
|
||||||
const recovery = new RecoveryManager();
|
const RecoveryManagerModule = await import('./management/recovery-manager');
|
||||||
const recovered = recovery.recoverAll();
|
const RecoveryManager = RecoveryManagerModule.default;
|
||||||
|
const recovery = new RecoveryManager();
|
||||||
|
const recovered = recovery.recoverAll();
|
||||||
|
|
||||||
if (recovered) {
|
if (recovered) {
|
||||||
recovery.showRecoveryHints();
|
recovery.showRecoveryHints();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// Recovery is best-effort - don't block basic CLI functionality
|
||||||
|
console.warn('[!] Recovery failed:', (err as Error).message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case: version command (check BEFORE profile detection)
|
// Special case: version command (check BEFORE profile detection)
|
||||||
|
|||||||
Reference in New Issue
Block a user