Skip to content

orElse

Promise.orElse(target, onRejected)

Catches rejected promises and handles them with onRejected. This is an alias for Promise.catch.

Example

ts
import { Promise } from "@monstermann/promise";

Promise.orElse(Promise.reject("error"), () => "fallback"); // Promise<"fallback">
ts
import { Promise } from "@monstermann/promise";

pipe(
    Promise.reject("error"),
    Promise.orElse(() => "fallback"),
); // Promise<"fallback">