Skip to content

Commit

Permalink
Async: Use except() rather than thenCatch().
Browse files Browse the repository at this point in the history
  • Loading branch information
e3ndr committed Dec 23, 2023
1 parent 228adc6 commit de9da54
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public Promise<Void> then(@NonNull PromiseConsumer<T> handler) {
}

/* ---------------- */
/* .thenCatch() chaining */
/* .except() chaining */
/* ---------------- */

/**
Expand All @@ -289,7 +289,7 @@ public Promise<Void> then(@NonNull PromiseConsumer<T> handler) {
* be of type R or T. You will have to check yourself and cast it to
* the appropriate type.
*/
public <R> Promise<?> thenCatch(@NonNull PromiseFunction<Throwable, R> handler) {
public <R> Promise<?> except(@NonNull PromiseFunction<Throwable, R> handler) {
PromiseResolver<Object> subpromiseResolver = withResolvers();
this.chainTo((result) -> {
try {
Expand Down Expand Up @@ -318,8 +318,8 @@ public <R> Promise<?> thenCatch(@NonNull PromiseFunction<Throwable, R> handler)
* be of type Void or T. You will have to check yourself and cast it
* to the appropriate type.
*/
public Promise<?> thenCatch(@NonNull PromiseConsumer<Throwable> handler) {
return this.thenCatch((throwable) -> {
public Promise<?> except(@NonNull PromiseConsumer<Throwable> handler) {
return this.except((throwable) -> {
handler.accept(throwable);
return null;
});
Expand Down Expand Up @@ -465,7 +465,7 @@ public static Promise<?> race(@NonNull Promise<?>... promises) {
resolver.resolve(v);
} catch (IllegalStateException ignored) {} // Already settled.
})
.thenCatch((t) -> {
.except((t) -> {
try {
resolver.reject(t);
} catch (IllegalStateException ignored) {} // Already settled.
Expand Down Expand Up @@ -510,7 +510,7 @@ public static Promise<?> any(@NonNull Promise<?>... promises) {
resolver.resolve(v);
} catch (IllegalStateException ignored) {} // Already settled.
})
.thenCatch((t) -> {
.except((t) -> {
if (rejectedCountDown.decrementAndGet() == 0) {
resolver.reject(new Exception("All Promises have rejected."));
}
Expand Down

0 comments on commit de9da54

Please sign in to comment.