Skip to content

Commit d01c6da

Browse files
committed
Either#trying can now throw any Throwable
1 parent 9b47b28 commit d01c6da

File tree

1 file changed

+11
-11
lines changed
  • src/main/java/com/jnape/palatable/lambda/adt

1 file changed

+11
-11
lines changed

src/main/java/com/jnape/palatable/lambda/adt/Either.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,26 +283,26 @@ public static <L, R> Either<L, R> fromMaybe(Maybe<R> maybe, Supplier<L> leftFn)
283283
*
284284
* @param supplier the supplier of the right value
285285
* @param leftFn a function mapping E to L
286-
* @param <E> the most contravariant exception that the supplier might throw
286+
* @param <T> the most contravariant exception that the supplier might throw
287287
* @param <L> the left parameter type
288288
* @param <R> the right parameter type
289289
* @return the supplier result as a right value, or leftFn's mapping result as a left value
290290
*/
291-
public static <E extends Exception, L, R> Either<L, R> trying(CheckedSupplier<E, ? extends R> supplier,
292-
Function<? super E, ? extends L> leftFn) {
293-
return Try.<E, R>trying(supplier::get).toEither(leftFn);
291+
public static <T extends Throwable, L, R> Either<L, R> trying(CheckedSupplier<T, ? extends R> supplier,
292+
Function<? super T, ? extends L> leftFn) {
293+
return Try.<T, R>trying(supplier::get).toEither(leftFn);
294294
}
295295

296296
/**
297297
* Attempt to execute the {@link CheckedSupplier}, returning its result in a right value. If the supplier throws an
298298
* exception, wrap it in a left value and return it.
299299
*
300300
* @param supplier the supplier of the right value
301-
* @param <E> the left parameter type (the most contravariant exception that supplier might throw)
301+
* @param <T> the left parameter type (the most contravariant exception that supplier might throw)
302302
* @param <R> the right parameter type
303303
* @return the supplier result as a right value, or a left value of the thrown exception
304304
*/
305-
public static <E extends Exception, R> Either<E, R> trying(CheckedSupplier<E, R> supplier) {
305+
public static <T extends Throwable, R> Either<T, R> trying(CheckedSupplier<T, R> supplier) {
306306
return trying(supplier, id());
307307
}
308308

@@ -312,12 +312,12 @@ public static <E extends Exception, R> Either<E, R> trying(CheckedSupplier<E, R>
312312
*
313313
* @param runnable the runnable
314314
* @param leftFn a function mapping E to L
315-
* @param <E> the most contravariant exception that the runnable might throw
315+
* @param <T> the most contravariant exception that the runnable might throw
316316
* @param <L> the left parameter type
317317
* @return {@link Unit} as a right value, or leftFn's mapping result as a left value
318318
*/
319-
public static <E extends Exception, L> Either<L, Unit> trying(CheckedRunnable<E> runnable,
320-
Function<? super E, ? extends L> leftFn) {
319+
public static <T extends Throwable, L> Either<L, Unit> trying(CheckedRunnable<T> runnable,
320+
Function<? super T, ? extends L> leftFn) {
321321
return Try.trying(runnable).toEither(leftFn);
322322
}
323323

@@ -326,10 +326,10 @@ public static <E extends Exception, L> Either<L, Unit> trying(CheckedRunnable<E>
326326
* exception, wrap it in a left value and return it.
327327
*
328328
* @param runnable the runnable
329-
* @param <E> the left parameter type (the most contravariant exception that runnable might throw)
329+
* @param <T> the left parameter type (the most contravariant exception that runnable might throw)
330330
* @return {@link Unit} as a right value, or a left value of the thrown exception
331331
*/
332-
public static <E extends Exception> Either<E, Unit> trying(CheckedRunnable<E> runnable) {
332+
public static <T extends Throwable> Either<T, Unit> trying(CheckedRunnable<T> runnable) {
333333
return trying(runnable, id());
334334
}
335335

0 commit comments

Comments
 (0)