ResponseError instantiations and improves messages so they are more descriptive, actionable, and user-friendly.
ResponseError is Factory’s internal error handling class used to throw HTTP-style errors with specific status codes. These error classes are used throughout the codebase to handle API errors.How it works
The script:- Finds files: Searches for all
.tsand.tsxfiles containing ResponseError classes - Filters smartly: Excludes
node_modules,.git,dist,build, and.nextdirectories - Identifies errors: Locates all ResponseError instantiations (400, 401, 403, 404, etc.)
- Improves messages: Makes them more descriptive and actionable
- Adds context: Includes what went wrong and potential fixes
- User-friendly language: Removes technical jargon
- Preserves metadata: Keeps error codes and metadata intact
Get the script
View full script source
View full script source
Prerequisites
Before you begin, complete the Droid Exec installation.Basic usage
Preview changes (dry run)
The dry run feature shows you exactly which files contain ResponseError instantiations and how many:- When
DRY_RUN=true: Counts all ResponseError instantiations without making changes - When
DRY_RUN=false(default): Actually improves the error messages using AI
- Estimate the scope of changes needed
- Test on a small directory first
- Plan your refactoring strategy
Apply refactoring
Once you’re ready, run the actual error message improvement:Real-world transformations
Example 1: Session Authentication
- Before
- After
Example 2: Bearer Token Authorization
- Before
- After
Best practices
Follow these best practices for safe and effective error message improvement.
