passsy / prefer-exceptionsr4
Prefer Exceptions Over Either
PublicReturn Future<T> and let failures throw instead of returning Future<Either<T>>, because a Future can fail anyway and Either only adds complexity and false safety.
Prefer Exceptions Over Either
Return Future<T> and let failures throw instead of returning Future<Either<T>>, because a Future can fail anyway and Either only adds complexity and false safety.
A Future<T> already encapsulates both successful results and potential failures. Avoid using Future<Either<T>>, as it introduces unnecessary complexity.
- A
Futurecan fail naturally (e.g.,TimeoutException), requiring try-catch handling regardless. - Wrapping results in
Eithermay create a false sense of safety, leading developers to overlook try-catch handling.