Auditing Your Code

Handling errors

Premium episode

This episode is included with faster. membership.

Unlock with membership

Episode 8

Handling errors

3:08PREMIUM

The "audit errors" command helps identify and fix error handling issues in codebases (Rust, TypeScript/TanStack Query). It checks for problems like:

  • Empty/Broad Catch Blocks: Catches that swallow errors without proper handling.
  • Lost Exceptions: Exceptions being swallowed entirely.
  • Bad Promise/Async Error Handling: Issues with unawaited Promises, missing catches in Promise chains, and floating async operations without error handling.
  • Inconsistent Error Message Quality: Suggesting improvements to user-facing error messages for better UX (e.g., avoid technical jargon, use specific app names instead of framework names).
  • Silent Catches/OKs: Catches or success handlers that don't log errors, making it difficult to detect failures.
  • Mixed Error Strategies: Redundant or confusing error handling logic (e.g., try/catch alongside onSuccess/onError).
  • Debug Logging in Catch Blocks: Encouraging proper error logging instead of debug statements.
  • Missing Operation Context: Ensuring proper context within closures.
  • Boolean Checks for Success: Suggesting improvements where a boolean value determines success.

The recommended approach is to:

  1. Run the "audit errors" command.
  2. Put the output into "plan mode" to review the suggested fixes.
  3. Correct the plan (e.g., customize user-facing error messages).
  4. Apply the corrected plan to fix the identified issues, focusing on fixing floating promises, missing catches, and silent OKs.