Get the FREE Ultimate OpenClaw Setup Guide →

Empty Catch Finder

Scanned
npx machina-cli add skill dcs-soni/awesome-claude-skills/empty-catch-finder --openclaw
Files (1)
SKILL.md
3.8 KB

Empty Catch Block Finder

Detect silent error handlers that cause mysterious production failures.

Why This Matters

Empty catch blocks are silent killers:

try {
  await saveOrder(order);
} catch (e) {
  // Silent failure - order lost, no evidence
}

This skill finds them before they cause production incidents.

Quick Start

Empty Catch Analysis:
- [ ] Step 1: Scan for empty catch blocks
- [ ] Step 2: Assess risk level
- [ ] Step 3: Generate fix suggestions

Workflow

Step 1: Scan for Empty Catches

Find all empty/silent catch blocks:

python scripts/find_empty_catches.py <directory>

Detects:

  • catch (e) {} - completely empty
  • catch (e) { /* comment */ } - only comments
  • except: pass - Python silent pass
  • if err != nil { } - Go ignored errors
  • catch { return; } - silent returns

Step 2: Assess Risk Level

Each catch is categorized by risk:

RiskPatternWhy Dangerous
šŸ”“ CriticalEmpty catch in async/database codeData loss, corruption
🟠 HighEmpty catch in API handlersSilent failures to users
🟔 MediumEmpty catch in utilitiesHidden bugs
🟢 LowEmpty catch in tests/scriptsUsually intentional

Step 3: Generate Fix Suggestions

Get suggested fixes:

python scripts/generate_fixes.py <directory> --output fixes.md

Fix patterns:

// āŒ Before: Silent failure
catch (e) {}

// āœ… After: Logged + handled
catch (e) {
  logger.error('Order save failed', { error: e, orderId: order.id });
  throw new OrderSaveError('Failed to save order', { cause: e });
}

Utility Scripts

ScriptPurpose
find_empty_catches.pyFind empty catch blocks
generate_fixes.pySuggest proper error handling

Language Support

LanguagePatterns Detected
JavaScript/TypeScriptcatch (e) {}, catch {}
Pythonexcept: pass, except Exception: ...
Javacatch (Exception e) {}
Goif err != nil { } (empty body)
C#catch (Exception) {}

See PATTERNS.md for full pattern reference.


Example

User: "Find silent error handlers in my codebase"

Output:

Found 8 empty catch blocks

šŸ”“ CRITICAL (2)
  src/services/payment.ts:45
    catch (e) {} // In async payment processing!

  src/db/users.ts:112
    catch (e) { return null; } // Hides DB errors

🟠 HIGH (3)
  src/api/orders.ts:78
    catch (error) { /* TODO: handle */ }

  ...

Integration with Linting

After fixing, prevent new empty catches:

ESLint:

{ "rules": { "no-empty": ["error", { "allowEmptyCatch": false }] } }

Python (Ruff):

[tool.ruff]
select = ["E722"]  # bare-except

Related Skills

  • incident-response-helper — Debug issues caused by silent failures
  • stale-todo-finder — Find // TODO: handle error comments

Source

git clone https://github.com/dcs-soni/awesome-claude-skills/blob/main/empty-catch-finder/SKILL.mdView on GitHub

Overview

Empty Catch Block Finder detects silent error handlers that swallow exceptions, helping teams prevent production incidents and hidden bugs. It targets mentions of silent failures, empty catches, ignored exceptions, or debugging mysterious issues.

How This Skill Works

The workflow scans code for empty or silent catches, classifies each finding by risk, and then generates practical fixes. It mirrors the skill's steps: Step 1 Scan for Empty Catches, Step 2 Assess Risk Level, Step 3 Generate Fix Suggestions.

When to Use It

  • When you suspect silent failures or missing error reporting in production
  • When debugging mysterious production issues caused by error swallowing
  • During code reviews to enforce proper error handling
  • When refactoring legacy code with empty catch blocks
  • When integrating linting to prevent empty catches from reappearing

Quick Start

  1. Step 1: Scan for empty catch blocks
  2. Step 2: Assess risk level
  3. Step 3: Generate fix suggestions

Best Practices

  • Scan codebases regularly for empty catches
  • Prioritize riskier paths like async or API handlers
  • Log errors and rethrow or wrap with meaningful messages
  • Avoid catch blocks that simply return or swallow errors
  • Add tests that exercise error paths and verify handling

Example Use Cases

  • catch (e) {} // Silent failure – order could be lost
  • catch (e) { return null; } // Hides DB errors
  • catch (error) { /* TODO: handle */ } // Missing implementation
  • if err != nil { } // Go: ignored error
  • except: pass // Python silent pass

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers ↗