Maps an error Result using the provided function. If the Result is successful, returns the success unchanged.
The type of the successful value
The type of the input error
The type of the output error
The Result to map the error of
Function to transform the error
A new Result with the transformed error, or the original success
const errorResult = err(new Error("Network error"))const enhancedError = mapErr(errorResult, err => new Error(`API call failed: ${err.message}`)) // err(Error("API call failed: Network error")) Copy
const errorResult = err(new Error("Network error"))const enhancedError = mapErr(errorResult, err => new Error(`API call failed: ${err.message}`)) // err(Error("API call failed: Network error"))
Maps an error Result using the provided function. If the Result is successful, returns the success unchanged.