Search in sources :

Example 1 with AmbiguousTimeoutException

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));
    }
}
Also used : RequestCanceledException(com.couchbase.client.core.error.RequestCanceledException) AmbiguousTimeoutException(com.couchbase.client.core.error.AmbiguousTimeoutException) UnambiguousTimeoutException(com.couchbase.client.core.error.UnambiguousTimeoutException) CancellationErrorContext(com.couchbase.client.core.error.context.CancellationErrorContext)

Aggregations

AmbiguousTimeoutException (com.couchbase.client.core.error.AmbiguousTimeoutException)1 RequestCanceledException (com.couchbase.client.core.error.RequestCanceledException)1 UnambiguousTimeoutException (com.couchbase.client.core.error.UnambiguousTimeoutException)1 CancellationErrorContext (com.couchbase.client.core.error.context.CancellationErrorContext)1