Prepared Docs

Prepared Docs

⌘K

    Loading navigation…

User

  1. Code Quality
  2. Javascript Patterns

JavaScript Patterns

Async/await and error handling patterns.

Quick Reference

Async/await:

  • Prefer async/await over .then()/.catch()
  • Always use try/catch with await
  • Use logger.errorAndReport() for error tracking
  • Use Promise.all() for concurrent operations

Error handling:

  • Normalize errors: err instanceof Error ? err : new Error(String(err))
  • Log context with errors
  • Re-throw when caller needs to handle

Async/Await Over Promises

Error Handling

Always Use Try/Catch

Error Normalization

Context in Error Logs

Promise.all() for Concurrent Operations

Error Recovery

Timeout Handling

Related Documentation

  • TypeScript Patterns - Type safety patterns
  • Eliminating Waterfalls - Async optimization
  • Writing Hooks - Async in React hooks

Reference Files

For more detailed technical guidance, see these reference files:

  • javascript-style SKILL.md

Previous

Code quality / TypeScript Patterns

Next

Code quality / Refactoring Guide

On this page

Quick Reference
Async/Await Over Promises
Error Handling
Always Use Try/Catch
Error Normalization
Context in Error Logs
Promise.all() for Concurrent Operations
Error Recovery
Timeout Handling
Related Documentation
Reference Files