use of com.couchbase.client.core.error.AmbiguousTimeoutException in project couchbase-jvm-clients by couchbase.
the class BaseRequest method cancel.
@Override
public void cancel(final CancellationReason reason, Function<Throwable, Throwable> exceptionTranslator) {
if (STATE_UPDATER.compareAndSet(this, State.INCOMPLETE, State.CANCELLED)) {
cancelTimeoutRegistration();
cancellationReason = reason;
final Throwable exception;
final String msg = this.getClass().getSimpleName() + ", Reason: " + reason;
final CancellationErrorContext ctx = new CancellationErrorContext(context());
if (reason == CancellationReason.TIMEOUT) {
exception = idempotent() ? new UnambiguousTimeoutException(msg, ctx) : new AmbiguousTimeoutException(msg, ctx);
} else {
exception = new RequestCanceledException(msg, reason, ctx);
}
response.completeExceptionally(exceptionTranslator.apply(exception));
}
}
Aggregations