Quickly define type-safe error structures for your frontend and backend communication.
⚠ Read Error Handling Guide →
Avoid using try/catch for every API call. By using a Result Pattern ({ success: boolean, data?: T, error?: E }), you force your code to handle failure cases explicitly, reducing unhandled runtime exceptions.
Define your error codes as string literals. This allows TypeScript to provide exhaustive checks in your switch statements, ensuring you've handled every possible error state from the backend.
For form validation errors, use a Record<string, string[]> structure. This mapping allows your frontend components to easily link error messages to specific form fields by their keys.
Select a preset that matches your project's architecture, customize the error codes to match your backend documentation, and copy the generated TypeScript directly into your shared types library.