diff options
| author | Jaana Dogan <[email protected]> | 2025-04-21 12:15:47 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-21 12:15:47 -0700 |
| commit | 53a5728009adf1e91115ee0eb839eafa00262adf (patch) | |
| tree | 2ad9b1a643f55ea22cc19946213f5790a9f2c8ce /packages/cli/src/gemini.ts | |
| parent | dea0782c891b2d849cc31c1364b32a9fb9a7a312 (diff) | |
Remove redundant else branches (#86)
Else branches are an anti pattern especially if you can easily return from the previous branch. Over time, else branches cause deep nesting and make code unreadable and unmaintainable. Remove elses where possible.
Diffstat (limited to 'packages/cli/src/gemini.ts')
| -rw-r--r-- | packages/cli/src/gemini.ts | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/packages/cli/src/gemini.ts b/packages/cli/src/gemini.ts index 60863c6a..97502399 100644 --- a/packages/cli/src/gemini.ts +++ b/packages/cli/src/gemini.ts @@ -54,20 +54,21 @@ process.on('unhandledRejection', (reason, _promise) => { ); console.warn('-----------------------------------------'); console.warn('Reason:', reason); - // No process.exit(1); - } else { - // Log other unexpected unhandled rejections as critical errors - console.error('========================================='); - console.error('CRITICAL: Unhandled Promise Rejection!'); - console.error('========================================='); - console.error('Reason:', reason); - console.error('Stack trace may follow:'); - if (!(reason instanceof Error)) { - console.error(reason); - } - // Exit for genuinely unhandled errors - process.exit(1); + return; + // No process.exit(1); Don't exit. + } + + // Log other unexpected unhandled rejections as critical errors + console.error('========================================='); + console.error('CRITICAL: Unhandled Promise Rejection!'); + console.error('========================================='); + console.error('Reason:', reason); + console.error('Stack trace may follow:'); + if (!(reason instanceof Error)) { + console.error(reason); } + // Exit for genuinely unhandled errors + process.exit(1); }); // --- Global Entry Point --- |
