throw
연산자(operator) 정의: throw(error: any, scheduler: Scheduler): Observable
Emit error on subscription.
Examples
Example 1: Throw error on subscription
//emits an error with specified value on subscription
const source = Rx.Observable.throw('This is an error!');
//output: 'Error: This is an error!'
const subscribe = source.subscribe({
next: val => console.log(val),
complete: () => console.log('Complete!'),
error: val => console.log(`Error: ${val}`)
});
Additional Resources
- throw - Official docs
- Creation operators: empty, never, and throw - André Staltz
Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/observable/ErrorObservable.ts