mini-effect
    Preparing search index...

    Type Alias FailureConstructor<T>

    FailureConstructor: new (options?: ErrorOptions) => Failure<T>

    A constructor type for tagged error classes produced by failure.

    Type Parameters

    • T extends string

      A string literal type used as the tag discriminator

    Type Declaration

      • new (options?: ErrorOptions): Failure<T>
      • Parameters

        • Optionaloptions: ErrorOptions

        Returns Failure<T>

    Instances created with new FailureConstructor(options?) extend Error and conform to the Failure shape, carrying a __tag property set to the tag string. The optional ErrorOptions parameter allows setting a cause for error chaining.

    import { failure } from "mini-effect";

    const NotFound = failure("NotFound");
    // ^? FailureConstructor<"NotFound">

    const err = new NotFound({ cause: "resource missing" });
    err.__tag; // "NotFound"