@praha/byethrow
    Preparing search index...

    Function mapError

    Applies a transformation function to the error value of a Result or ResultAsync. If the input is a Success, it will be returned unchanged.

    The input Result or ResultAsync.

    The transformed error value type.

    import { Result } from '@praha/byethrow';

    const result = Result.pipe(
    Result.fail('NotFound'),
    Result.mapError((error) => new Error(error)),
    );
    // { type: 'Failure', error: Error('NotFound') }
    import { Result } from '@praha/byethrow';

    const result = Result.pipe(
    Result.succeed(123),
    Result.mapError((error) => new Error(error)),
    );
    // { type: 'Success', value: 123 }

    pipe - It is recommended to use this function with the pipe function for better readability and composability.