Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ReactiveX/rxjs/llms.txt
Use this file to discover all available pages before exploring further.
throwError
Creates an Observable that will create an error instance and push it to the consumer as an error immediately upon subscription.Import
Type Signature
Parameters
A factory function that returns the error to emit. Called on each subscription.
Returns
An Observable that errors immediately upon subscription.
Description
Creates an Observable that errors immediately. Useful for error handling and testing.Examples
Basic Error
Dynamic Error
Common Use Cases
Conditional Error
Testing Error Paths
Important Note
Often you can just
throw an error in operators instead of using throwError. RxJS will catch it and emit as an error.Related Operators
- of - Emit values successfully
- defer - Lazy Observable creation
- EMPTY - Observable that completes immediately
