Skip to content

throwError() function

toErrorの結果をスローします。

Signature:

typescript
throwError: <T, E extends Error>(toError: (input: T) => E) =>
  (input: T) =>
    never;

Example

ts
const result: never = pipe(
  0,

  throwError((input) => Error(`input is ${input}`)),

  (input: never) => {
    // unreachable point
  },
);

Open Source Code

Released under the Apache-2.0 License.