Error objects, define error types with metadata, HTTP codes, and remediation steps.
Why Typed Errors?
Type Safety
Catch specific error types with full TypeScript support
HTTP Integration
Map errors to HTTP status codes automatically
Remediation
Include user-facing solutions in error definitions
Observability
Structured error data for logs and monitoring
Basic Usage
Define errors withr.error() and use them anywhere:
RunnerError Class
All errors created withr.error() extend RunnerError:
Defining Errors
Basic Error
With HTTP Code
With Remediation
With Validation Schema
Error Methods
Throw the error with data
Create error instance without throwing
Type guard to check if error matches
Mark error as optional dependency
Error Contracts
Declare which errors a task can throw:Checking Error Types
Generic RunnerError Check
Specific Error Check
Partial Data Matching
Error Boundaries
Catch unhandled errors at the process level:Built-in Errors
Runner provides common error types:HTTP Status Codes
Define errors with standard HTTP codes:Express Integration
Dynamic Remediation
Error Metadata
Best Practices
Use Semantic IDs
Name errors clearly:
app.errors.InvalidCredentials, not error1Include Context
Add relevant data to error objects for debugging
Provide Remediation
Tell users how to fix the problem, not just what went wrong
Use Error Contracts
Declare possible errors with
.throws() for documentationCommon Patterns
Validation Errors
Retry with Error Filtering
Error Wrapping
See Also
- Tasks - Task execution and error handling
- Middleware - Error handling in middleware
- Testing - Testing error scenarios
- Logging - Structured error logging