- RxJS Tutorial
- RxJS - Home
- RxJS - Overview
- RxJS - Environment Setup
- RxJS - Latest Updates
- RxJS - Observables
- RxJS - Operators
- RxJS - Working with Subscription
- RxJS - Working with Subjects
- RxJS - Working with Scheduler
- RxJS - Working with RxJS & Angular
- RxJS - Working with RxJS & ReactJS
- RxJS Useful Resources
- RxJS - Quick Guide
- RxJS - Useful Resources
- RxJS - Discussion
RxJS - Creation Operator throwError
This operator will create an observable that will notify an error.
Syntax
throwError(error: any): Observable
Parameters
error − The argument the operator takes in is the error that you need to notify.
Return value
It returns an observable that will notify an error.
Example
import { throwError, concat, of } from 'rxjs'; const result =throwError(new Error('error occurred')); result.subscribe(x => console.log(x), e => console.error(e));
Output
Advertisements