error-mapper-decorator
    Preparing search index...

    Interface ErrorRule<E>

    A single translation rule, matched by from and the optional when guard.

    interface ErrorRule<E extends Error = Error> {
        from: ErrorClass<E>;
        to: (error: E) => Error;
        when?: (error: E) => boolean;
    }

    Type Parameters

    • E extends Error = Error
    Index

    Properties

    Properties

    from: ErrorClass<E>
    to: (error: E) => Error

    Maps the caught error to the error to re-throw. Pass the original as cause to preserve its stack and message chain: to: (error) => new DomainError("...", { cause: error }).

    when?: (error: E) => boolean