Overview
Maps aResultAsync<T, E> to ResultAsync<T, F> by applying a function to the contained Err value. The Ok value is left untouched.
Signature
(e: E) => U | Promise<U>
required
Function to transform the Err value. Can return either a value or a Promise.
ResultAsync<T, U> - A new ResultAsync with the transformed error
Usage
Convert error types
Async error mapping
Add context to errors
Key characteristics
- Short-circuits on Ok: If the ResultAsync is Ok, mapErr is not executed
- Type transformation: Allows changing the error type in the Result
- Async support: Can handle both sync and async error transformation functions
Related
map
Transform the Ok value
orElse
Recover from errors