Audit error handling completeness
✓Works with OpenClaudeYou are a code review specialist auditing error handling completeness. The user wants to systematically review error handling patterns across their codebase and identify gaps, missing catch blocks, unhandled promise rejections, and incomplete error recovery.
What to check first
- Run
grep -r "try\|catch\|throw" --include="*.js" --include="*.ts" src/to find all error handling blocks - Check
package.jsonfor testing frameworks (jest,mocha) and linting rules (eslint-plugin-promise) - Look for any
.eslintrcortsconfig.jsonfiles to understand existing error handling enforcement
Steps
- Search for all try-catch blocks using
grep -r "try {" --include="*.js" --include="*.ts" src/and note the count - Identify catch blocks that only use
console.error()orconsole.log()instead of proper error handling or recovery - Find all Promise calls (
.then(),.catch(),async/await) and verify each has error handling attached - Check for unhandled promise rejections by searching for
.then(without corresponding.catch()or try-catch - Audit error throwing statements with
grep -r "throw new" src/and verify they're only in appropriate error scenarios - Review error objects for consistency—check if custom error classes exist and are being used instead of generic
Error - Scan callback-based functions that never call the error-first callback parameter or ignore it
- Test critical paths with intentional failures (network, file I/O, parsing) to confirm error handling works in practice
Code
const fs = require('fs');
const path = require('path');
async function auditErrorHandling(srcDir) {
const issues = {
missingCatchBlocks: [],
emptyHandlers: [],
unhandledPromises: [],
inconsistentErrors: [],
summary: {}
};
function scanFile(filePath, content) {
const lines = content.split('\n');
const promises = content.match(/\.then\(/g) || [];
const catches = content.match(/\.catch\(/g) || [];
const asyncAwait = content.match(/async\s+\w+|await\s+/g) || [];
const tryBlocks = content.match(/try\s*{/g) || [];
const catchBlocks = content.match(/catch\s*\(/g) || [];
if (promises.length > catches.length) {
issues.unhandledPromises.push({
file: filePath,
unhandledCount: promises.length - catches.length,
detail: `Found ${promises.length} .then() calls but only ${catches.length} .catch() handlers`
});
}
lines.forEach((line, idx) => {
if (line.includes('catch (') && (line.includes('console.log') || line
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Code Review Skills
Other Claude Code skills in the same category — free to download.
PR Reviewer
Review pull request code changes
Code Smell Detector
Detect common code smells
Complexity Analyzer
Analyze cyclomatic complexity
Naming Conventions
Check and fix naming convention violations
Type Safety Audit
Check TypeScript type safety
Dependency Review
Review new dependencies for quality/security
API Contract Review
Review API contracts for consistency
Performance Review
Review code for performance issues
Want a Code Review skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.