diff --git a/vavr/generator/Generator.scala b/vavr/generator/Generator.scala index 1a9128ba1d..86a063c28a 100644 --- a/vavr/generator/Generator.scala +++ b/vavr/generator/Generator.scala @@ -1570,9 +1570,9 @@ def generateMainClasses(): Unit = { * Applies this function to ${arguments(i)} and returns the result. ${(0 to i).gen(j => if (j == 0) "*" else s"* @param t$j argument $j")("\n")} * @return the result of function application - * ${checked.gen("@throws Throwable if something goes wrong applying this function to the given arguments")} + * ${checked.gen("@throws Exception if something goes wrong applying this function to the given arguments")} */ - R apply($paramsDecl)${checked.gen(" throws Throwable")}; + R apply($paramsDecl)${checked.gen(" throws Exception")}; ${(1 until i).gen(j => { val partialApplicationArgs = (1 to j).gen(k => s"T$k t$k")(", ") diff --git a/vavr/src-gen/main/java/io/vavr/CheckedFunction0.java b/vavr/src-gen/main/java/io/vavr/CheckedFunction0.java index a73b8a1f9c..e103d9859b 100644 --- a/vavr/src-gen/main/java/io/vavr/CheckedFunction0.java +++ b/vavr/src-gen/main/java/io/vavr/CheckedFunction0.java @@ -137,9 +137,9 @@ static CheckedFunction0 narrow(CheckedFunction0 f) { * Applies this function to no arguments and returns the result. * * @return the result of function application - * @throws Throwable if something goes wrong applying this function to the given arguments + * @throws Exception if something goes wrong applying this function to the given arguments */ - R apply() throws Throwable; + R apply() throws Exception; @Override default int arity() { diff --git a/vavr/src-gen/main/java/io/vavr/CheckedFunction1.java b/vavr/src-gen/main/java/io/vavr/CheckedFunction1.java index e226694818..23f53ba6e0 100644 --- a/vavr/src-gen/main/java/io/vavr/CheckedFunction1.java +++ b/vavr/src-gen/main/java/io/vavr/CheckedFunction1.java @@ -154,9 +154,9 @@ static CheckedFunction1 identity() { * * @param t1 argument 1 * @return the result of function application - * @throws Throwable if something goes wrong applying this function to the given arguments + * @throws Exception if something goes wrong applying this function to the given arguments */ - R apply(T1 t1) throws Throwable; + R apply(T1 t1) throws Exception; @Override default int arity() { diff --git a/vavr/src-gen/main/java/io/vavr/CheckedFunction2.java b/vavr/src-gen/main/java/io/vavr/CheckedFunction2.java index 9cba415d36..3a54fe611e 100644 --- a/vavr/src-gen/main/java/io/vavr/CheckedFunction2.java +++ b/vavr/src-gen/main/java/io/vavr/CheckedFunction2.java @@ -152,9 +152,9 @@ static CheckedFunction2 narrow(CheckedFunction2 CheckedFunction3 narrow(CheckedFunction3 CheckedFunction4 narrow(CheckedFun * @param t3 argument 3 * @param t4 argument 4 * @return the result of function application - * @throws Throwable if something goes wrong applying this function to the given arguments + * @throws Exception if something goes wrong applying this function to the given arguments */ - R apply(T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable; + R apply(T1 t1, T2 t2, T3 t3, T4 t4) throws Exception; /** * Applies this function partially to one argument. diff --git a/vavr/src-gen/main/java/io/vavr/CheckedFunction5.java b/vavr/src-gen/main/java/io/vavr/CheckedFunction5.java index 0ebfcec00d..4033ea98a3 100644 --- a/vavr/src-gen/main/java/io/vavr/CheckedFunction5.java +++ b/vavr/src-gen/main/java/io/vavr/CheckedFunction5.java @@ -172,9 +172,9 @@ static CheckedFunction5 narrow(Ch * @param t4 argument 4 * @param t5 argument 5 * @return the result of function application - * @throws Throwable if something goes wrong applying this function to the given arguments + * @throws Exception if something goes wrong applying this function to the given arguments */ - R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable; + R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Exception; /** * Applies this function partially to one argument. diff --git a/vavr/src-gen/main/java/io/vavr/CheckedFunction6.java b/vavr/src-gen/main/java/io/vavr/CheckedFunction6.java index 163db7a9fe..c42d82b079 100644 --- a/vavr/src-gen/main/java/io/vavr/CheckedFunction6.java +++ b/vavr/src-gen/main/java/io/vavr/CheckedFunction6.java @@ -179,9 +179,9 @@ static CheckedFunction6 n * @param t5 argument 5 * @param t6 argument 6 * @return the result of function application - * @throws Throwable if something goes wrong applying this function to the given arguments + * @throws Exception if something goes wrong applying this function to the given arguments */ - R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) throws Throwable; + R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) throws Exception; /** * Applies this function partially to one argument. diff --git a/vavr/src-gen/main/java/io/vavr/CheckedFunction7.java b/vavr/src-gen/main/java/io/vavr/CheckedFunction7.java index d3b34b247c..450991a2e7 100644 --- a/vavr/src-gen/main/java/io/vavr/CheckedFunction7.java +++ b/vavr/src-gen/main/java/io/vavr/CheckedFunction7.java @@ -186,9 +186,9 @@ static CheckedFunction7 CheckedFunction8 { * Performs side-effects. * * @param t a value of type {@code T} - * @throws Throwable if an error occurs + * @throws Exception if an error occurs */ - void accept(T t) throws Throwable; + void accept(T t) throws Exception; /** * Returns a chained {@code CheckedConsumer} that first executes {@code this.accept(t)} diff --git a/vavr/src/main/java/io/vavr/CheckedPredicate.java b/vavr/src/main/java/io/vavr/CheckedPredicate.java index 3c8f59ad13..5bfdba3778 100644 --- a/vavr/src/main/java/io/vavr/CheckedPredicate.java +++ b/vavr/src/main/java/io/vavr/CheckedPredicate.java @@ -32,9 +32,9 @@ public interface CheckedPredicate { * * @param t the input argument * @return {@code true} if the input argument matches the predicate, otherwise {@code false} - * @throws Throwable if an error occurs + * @throws Exception if an error occurs */ - boolean test(T t) throws Throwable; + boolean test(T t) throws Exception; /** * Negates this predicate. diff --git a/vavr/src/main/java/io/vavr/CheckedRunnable.java b/vavr/src/main/java/io/vavr/CheckedRunnable.java index bf1bce218e..32bb38efcd 100644 --- a/vavr/src/main/java/io/vavr/CheckedRunnable.java +++ b/vavr/src/main/java/io/vavr/CheckedRunnable.java @@ -28,7 +28,7 @@ public interface CheckedRunnable { /** * Performs side-effects. * - * @throws Throwable if an error occurs + * @throws Exception if an error occurs */ - void run() throws Throwable; + void run() throws Exception; } diff --git a/vavr/src/test/java/io/vavr/concurrent/Concurrent.java b/vavr/src/test/java/io/vavr/concurrent/Concurrent.java index 124b76484c..6f79c10e58 100644 --- a/vavr/src/test/java/io/vavr/concurrent/Concurrent.java +++ b/vavr/src/test/java/io/vavr/concurrent/Concurrent.java @@ -68,10 +68,17 @@ static CheckedFunction0 zZz(T value) { }; } - static CheckedFunction0 zZz(X exception) { + static CheckedFunction0 zZz(X exception) { return () -> { zZz(); throw exception; }; } + + static CheckedFunction0 zZz(X error) { + return () -> { + zZz(); + throw error; + }; + } } diff --git a/vavr/src/test/java/io/vavr/concurrent/FutureTest.java b/vavr/src/test/java/io/vavr/concurrent/FutureTest.java index 2b2c2e83f0..3ec8179ff3 100644 --- a/vavr/src/test/java/io/vavr/concurrent/FutureTest.java +++ b/vavr/src/test/java/io/vavr/concurrent/FutureTest.java @@ -1151,14 +1151,14 @@ private static Future blocking(CheckedRunnable computation) { private static Future blocking(CheckedFunction0 computation) { return Future.of(() -> { final AtomicReference result = new AtomicReference<>(null); - final AtomicReference errorRef = new AtomicReference<>(null); + final AtomicReference errorRef = new AtomicReference<>(null); ForkJoinPool.managedBlock(new ForkJoinPool.ManagedBlocker() { boolean releasable = false; @Override public boolean block() throws InterruptedException { try { result.set(computation.apply()); - } catch(Throwable x) { + } catch(Exception x) { errorRef.set(x); } return releasable = true; @@ -1168,7 +1168,7 @@ public boolean isReleasable() { return releasable; } }); - final Throwable error = errorRef.get(); + final Exception error = errorRef.get(); if (error != null) { throw error; } else { diff --git a/vavr/src/test/java/io/vavr/control/TryTest.java b/vavr/src/test/java/io/vavr/control/TryTest.java index 907a2cbf6e..b97dbce957 100644 --- a/vavr/src/test/java/io/vavr/control/TryTest.java +++ b/vavr/src/test/java/io/vavr/control/TryTest.java @@ -907,7 +907,7 @@ public void shouldReturnRecoveredValueOnFailure(){ @Test public void shouldNotRecoverFailureWhenExceptionTypeIsntAssignable(){ - final Throwable error = new IllegalStateException(FAILURE); + final Exception error = new IllegalStateException(FAILURE); assertThat(Try.of(() -> { throw error; }).recoverWith(Error.class, success()).getCause()).isSameAs(error); }