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