Problem
12 locations across the codebase use empty catch {} blocks that silently swallow errors. The most critical case is in token-storage.ts:
// src/common/token-storage.ts:41
try {
const encrypted = fs.readFileSync(tokenPath, "utf8").trim();
return decryptToken(encrypted);
} catch {
return null; // corrupted token → user sees "No API token found"
}
A user with a corrupted token file gets "No API token found" instead of "Your stored token is corrupted" — sending them on a debugging wild goose chase.
All locations
| File |
Line |
Impact |
src/common/token-storage.ts |
42 |
High — corrupted token invisible to user |
src/commands/auth.ts |
136, 142, 213, 229, 257 |
Medium — various auth flow fallbacks |
src/services/file-service.ts |
179, 262 |
Medium — file access/stat errors lost |
src/common/identifier.ts |
38 |
Low — intentional try-parse pattern |
src/common/embed-parser.ts |
62, 71 |
Low — URL parse fallback |
src/commands/documents.ts |
68 |
Low — URL parse fallback |
Expected behavior
token-storage.ts: Distinguish between "file not found" (return null) and "decryption failed" (log warning to stderr, return null)
auth.ts: At minimum, add inline comments explaining what errors are expected
file-service.ts: Surface the underlying error message in the result
- Low-impact locations: Add a comment explaining the intentional swallow, or narrow the catch to expected error types
Acceptance criteria
Problem
12 locations across the codebase use empty
catch {}blocks that silently swallow errors. The most critical case is intoken-storage.ts:A user with a corrupted token file gets "No API token found" instead of "Your stored token is corrupted" — sending them on a debugging wild goose chase.
All locations
src/common/token-storage.tssrc/commands/auth.tssrc/services/file-service.tssrc/common/identifier.tssrc/common/embed-parser.tssrc/commands/documents.tsExpected behavior
token-storage.ts: Distinguish between "file not found" (return null) and "decryption failed" (log warning to stderr, return null)auth.ts: At minimum, add inline comments explaining what errors are expectedfile-service.ts: Surface the underlying error message in the resultAcceptance criteria
catch {}blocks remain without either error handling or an explanatory commenttoken-storage.tsprints a warning to stderr when decryption fails