FieldedText TypeScript Library
    Preparing search index...

    Class FtErr<T, E>

    Represents a failed result.

    This class is used as the error branch of Result. It stores the error value and exposes methods for composing and reusing error information.

    Type Parameters

    • T = undefined

      The successful value type for the result branch, defaulting to undefined.

    • E = string

      The error type, defaulting to string.

    Index
    • Creates a failed result with the provided error.

      Type Parameters

      • T = undefined

        The successful value type for the result branch, defaulting to undefined.

      • E = string

        The error type, defaulting to string.

      Parameters

      • error: E

        The error value produced by the failed operation.

      Returns FtErr<T, E>

    error: E
    • Wraps this error in a higher-level error message.

      Type Parameters

      • OuterT = undefined

        The success value type of the wrapped result.

      Parameters

      • outerError: string

        A context label or prefix to prepend to the original error.

      Returns FtErr<OuterT, string>

      A new Err instance whose message is prefixed with outerError.

    • Wraps this error and resolves it as a promise.

      Type Parameters

      • OuterT = undefined

        The success value type of the wrapped result.

      Parameters

      • outerError: string

        A context label or prefix to prepend to the original error.

      Returns Promise<FtErr<OuterT, string>>

      A promise that resolves to the wrapped error instance.

    • Recreates this error with a different success generic parameter.

      This is useful when an operation fails but the type of a successful value changes in a surrounding call path.

      Type Parameters

      • NewT

        The replacement success value type.

      Returns FtErr<NewT, E>

      A new Err instance preserving the same error payload.

    • Returns true when this instance represents a failed result.

      This method is intended for type narrowing when handling a Result.

      Returns this is FtErr<T, E>

    • Returns true when this instance represents a successful result.

      This is always false for Err.

      Returns this is FtOk<T, E>