@Test public void testWithUncheckedExceptionSubclass() { assertEquals(SPECIFIC, Uni.createFrom() .item(Unchecked.supplier(this::numberSupplierThrowingNumberFormatException)) .onFailure(Caused.by(IllegalArgumentException.class)) .recoverWithItem(SPECIFIC) .onFailure() .recoverWithItem(GENERIC) .await() .indefinitely()); }
public static Predicate<Throwable> by(Class<? extends Throwable> cause) { if (cause == null) { throw new IllegalArgumentException("You must provide a cause class"); } return t -> { if (t.getCause() == null) { return cause.isAssignableFrom(t.getClass()); } return cause.isAssignableFrom(t.getCause().getClass()); }; }
Caused { public static Predicate<Throwable> by(Class<? extends Throwable> cause) { if (cause == null) { throw new IllegalArgumentException("You must provide a cause class"); } return t -> { if (t.getCause() == null) { return cause.isAssignableFrom(t.getClass()); } return cause.isAssignableFrom(t.getCause().getClass()); }; } }
Caused { public static Predicate<Throwable> by(Class<? extends Throwable> cause) { if (cause == null) { throw new IllegalArgumentException("You must provide a cause class"); } return t -> { if (t.getCause() == null) { return cause.isAssignableFrom(t.getClass()); } return cause.isAssignableFrom(t.getCause().getClass()); }; }  }
Caused { public static Predicate<Throwable> by(Class<? extends Throwable> cause) { if (cause == null) { throw new IllegalArgumentException("You must provide a cause class"); } return t -> { if (t.getCause() == null) { return cause.isAssignableFrom(t.getClass()); } return cause.isAssignableFrom(t.getCause().getClass()); }; }  static Predicate<Throwable> by(Class<? extends Throwable> cause); }
Caused { public static Predicate<Throwable> by(Class<? extends Throwable> cause) { if (cause == null) { throw new IllegalArgumentException("You must provide a cause class"); } return t -> { if (t.getCause() == null) { return cause.isAssignableFrom(t.getClass()); } return cause.isAssignableFrom(t.getCause().getClass()); }; }  static Predicate<Throwable> by(Class<? extends Throwable> cause);  }