Rxjs-create-operator-throwerror

提供:Dev Guides
2020年6月23日 (火) 01:13時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

RxJS-作成オペレーターthrowError

このオペレーターは、エラーを通知するオブザーバブルを作成します。

構文

throwError(error: any): Observable

パラメーター

*_error_* -オペレーターが受け取る引数は、通知する必要があるエラーです。

戻り値

エラーを通知するオブザーバブルを返します。

import { throwError, concat, of } from 'rxjs';

const result =throwError(new Error('error occurred'));
result.subscribe(x => console.log(x), e => console.error(e));

出力

throwError演算子