better-returns
    Preparing search index...

    Function map_error

    • Transforms the error value of a Result using a mapping function. If the result is Err, the apply function is called with its error value, and a new Err result containing the transformed error value is returned. If the result is Ok, it is returned unchanged.

      Type Parameters

      • T

        The type of the successful value.

      • E

        The original type of the error value.

      • U

        The new type of the error value after transformation.

      Parameters

      • result: Result<T, E>

        The result whose error value to map.

      • apply: (value: E) => U

        The function to apply to the error value.

      Returns Result<T, U>

      A new Result with the mapped error value, or the original Ok.