Overview
Handles theErr case of a ResultAsync by applying a recovery function. Useful for error recovery, fallbacks, and error transformation.
Signature
(e: E) => Result<U, A> | ResultAsync<U, A>
required
Function that takes the Err value and returns a new Result or ResultAsync
ResultAsync<U | T, A> - A ResultAsync with potentially recovered value
Usage
Simple fallback
Conditional recovery
Multi-tier fallback
Key characteristics
- Only runs on Err: If the ResultAsync is Ok, orElse is not executed
- Can change type: The recovery function can return a different value type
- Error type changes: The new error type replaces the original
Related
andThen
Chain successful operations
unwrapOr
Provide a simple default value