UNPKG

pi-lens

Version:

Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo

67 lines (55 loc) • 1.57 kB
# Empty Catch Block # Detects catch blocks that silently swallow errors id: empty-catch name: Empty Catch Block severity: error category: reliability defect_class: silent-error inline_tier: blocking language: typescript message: "Empty catch block — properly handle or log the error" description: | Silently swallowing errors makes debugging impossible. ✅ PROPER FIXES (choose one): 1. Log the error: console.error(`[context] Failed to X:`, err) 2. Rethrow if can't handle: throw err 3. Return a safe default: return null / return [] / return defaultValue 4. Handle specific errors: if (err.code === 'ENOENT') { ... } 5. Propagate to caller: callback(err) / reject(err) ❌ NOT ACCEPTABLE: - void err; (just references variable, does nothing) - /* ignored */ comments without action - console.log without the error object query: | (catch_clause (identifier) @ERR (statement_block) @BODY) # Post-filter: Check if body is effectively empty (ignoring comments) post_filter: empty_body # Capture metavariables metavars: - ERR # The error parameter name - BODY # The catch block body # Additional metadata tags: - security - debugging - reliability - best-practice # Examples for documentation examples: bad: | try { await fetch('/api'); } catch (err) { // Empty - BAD! } good: | try { await fetch('/api'); } catch (err) { console.error('[API] Fetch failed:', err); throw err; // or return safe default } # Auto-fix available has_fix: false