Skip to content
This repository was archived by the owner on Dec 20, 2022. It is now read-only.

Latest commit

 

History

History
52 lines (34 loc) · 8.43 KB

File metadata and controls

52 lines (34 loc) · 8.43 KB

throwError

function throwError<GError>(
  error: GError,
): IObservable<IErrorNotification<GError>>

Creates an Observable, which on subscribe, will emit error in a error Notification.

It is somehow equivalent of a Promise.reject.

Diagram

Examples

Example 1

const subscribe = throwError(new Error(`Aborted`));

subscribe((notification) => {
  console.log(notification.name, notification.value);
});

Output:

'error', Error(`Aborted`)

Example 2

const subscribe = throwError(new Error(`Aborted`));

toPromiseLast(subscribe)
  .catch((value: unknown) => {
    console.log(value);
  });

Output:

Error(`Aborted`)