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') } Copy
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 } Copy
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.
Applies a transformation function to the error value of a Result or ResultAsync. If the input is a Success, it will be returned unchanged.
Type Param: R1
The input Result or ResultAsync.
Type Param: E2
The transformed error value type.
Example: Failure Case (unchanged)
Example: Success Case (unchanged)
See
pipe - It is recommended to use this function with the pipe function for better readability and composability.