static Exception distinguishNotFound(final String message) { Pattern p = Pattern.compile("The messaging entity .* could not be found"); Matcher m = p.matcher(message); if (m.find()) { return new IllegalEntityException(message); } else { return new EventHubException(true, String.format(ClientConstants.AMQP_REQUEST_FAILED_ERROR, AmqpResponseCode.NOT_FOUND, message)); } }
static Exception amqpResponseCodeToException(final int statusCode, final String statusDescription) { final AmqpResponseCode amqpResponseCode = AmqpResponseCode.valueOf(statusCode); if (amqpResponseCode == null) return new EventHubException(true, String.format(ClientConstants.AMQP_REQUEST_FAILED_ERROR, statusCode, statusDescription)); switch (amqpResponseCode) { case BAD_REQUEST: return new IllegalArgumentException(String.format(ClientConstants.AMQP_REQUEST_FAILED_ERROR, statusCode, statusDescription)); case NOT_FOUND: return ExceptionUtil.distinguishNotFound(statusDescription); case FORBIDDEN: return new QuotaExceededException(String.format(ClientConstants.AMQP_REQUEST_FAILED_ERROR, statusCode, statusDescription)); case UNAUTHORIZED: return new AuthorizationFailedException(String.format(ClientConstants.AMQP_REQUEST_FAILED_ERROR, statusCode, statusDescription)); default: return new EventHubException(true, String.format(ClientConstants.AMQP_REQUEST_FAILED_ERROR, statusCode, statusDescription)); } }
this.onRemoteSessionOpenError.accept( null, new EventHubException( false, String.format("onSessionLocalOpen entityName[%s], underlying IO of reactorDispatcher faulted with error: %s",
@Override public void onClose(ErrorCondition condition) { if (condition == null || condition.getCondition() == null) { this.cancelPendingRequests( new EventHubException( ClientConstants.DEFAULT_IS_TRANSIENT, "The underlying request-response channel closed, recreate the channel and retry the request.")); if (onClose != null) onLinkCloseComplete(null); } else { this.onError(ExceptionUtil.toException(condition)); } }
? new EventHubException(true, String.format(Locale.US, "Entity(%s): client encountered transient error for unknown reasons, please retry the operation.", this.sendPath)) : completionException;
? new EventHubException(true, String.format(Locale.US, "Entity(%s): client encountered transient error for unknown reasons, please retry the operation.", this.receivePath)) : exception;
this.cleanupFailedSend( pendingSendWorkItem, new EventHubException(false, String.format(Locale.US, "Entity(%s): send operation failed while scheduling a retry on Reactor, see cause for more details.", this.sendPath), this.cleanupFailedSend(pendingSendWorkItem, new OperationCancelledException(outcome.toString())); } else { this.cleanupFailedSend(pendingSendWorkItem, new EventHubException(false, outcome.toString()));
cause); } else { sbException = new EventHubException( true, String.format(Locale.US, "%s, %s", message, ExceptionUtil.getTrackingIDAndTimeToLog()),
lastException = new EventHubException(true, "timed out"); completeWith = null; } else if (error instanceof Exception) {
return new EventHubException(ClientConstants.DEFAULT_IS_TRANSIENT, new TimeoutException(errorCondition.getDescription())); } else if (errorCondition.getCondition() == ClientConstants.SERVER_BUSY_ERROR) { return new ServerBusyException(errorCondition.getDescription()); return new PayloadSizeExceededException(errorCondition.getDescription()); } else if (errorCondition.getCondition() == AmqpErrorCode.InternalError) { return new EventHubException(true, new AmqpException(errorCondition)); } else if (errorCondition.getCondition() == ClientConstants.ARGUMENT_ERROR) { return new EventHubException(false, errorCondition.getDescription(), new AmqpException(errorCondition)); } else if (errorCondition.getCondition() == ClientConstants.ARGUMENT_OUT_OF_RANGE_ERROR) { return new EventHubException(false, errorCondition.getDescription(), new AmqpException(errorCondition)); } else if (errorCondition.getCondition() == AmqpErrorCode.NotImplemented) { return new UnsupportedOperationException(errorCondition.getDescription()); return new UnsupportedOperationException(errorCondition.getDescription()); } else if (errorCondition.getCondition() == ClientConstants.PARTITION_NOT_OWNED_ERROR) { return new EventHubException(false, errorCondition.getDescription()); } else if (errorCondition.getCondition() == ClientConstants.STORE_LOCK_LOST_ERROR) { return new EventHubException(false, errorCondition.getDescription()); } else if (errorCondition.getCondition() == AmqpErrorCode.AmqpLinkDetachForced) { return new EventHubException(true, new AmqpException(errorCondition)); } else if (errorCondition.getCondition() == AmqpErrorCode.ResourceLimitExceeded) { return new QuotaExceededException(new AmqpException(errorCondition)); return new EventHubException(ClientConstants.DEFAULT_IS_TRANSIENT, errorCondition.getDescription());
new EventHubException(false /* is transient */, "test")); consumer.poll(Collections.singleton(ssp), 0).get(ssp); Assert.assertEquals(consumer.recentRetryAttempts.size(), 0); eventHubClientWrapperFactory.triggerError(consumer.streamPartitionHandlers, new EventHubException(false /* is transient */, "test")); consumer.poll(Collections.singleton(ssp), 0).get(ssp); Assert.assertNotNull("reconnect task should have been submitted", consumer.reconnectTaskStatus); new EventHubException(false /* is transient */, "test")); consumer.poll(Collections.singleton(ssp), 0).get(ssp); Assert.assertEquals("there shouldn't be another retry task within min retry interval", consumer.reconnectTaskStatus, new EventHubException(false /* is transient */, "test")); try { consumer.poll(Collections.singleton(ssp), 0).get(ssp);