in pulsar-client-api/src/main/java/org/apache/pulsar/client/api/PulsarClientException.java [1043:1135]
public static PulsarClientException unwrap(Throwable t) {
if (t instanceof PulsarClientException) {
return (PulsarClientException) t;
} else if (t instanceof RuntimeException) {
throw (RuntimeException) t;
} else if (t instanceof InterruptedException) {
return new PulsarClientException(t);
} else if (!(t instanceof ExecutionException)) {
// Generic exception
return new PulsarClientException(t);
}
// Unwrap the exception to keep the same exception type but a stack trace that includes the application calling
// site
Throwable cause = t.getCause();
String msg = cause.getMessage();
PulsarClientException newException;
if (cause instanceof TimeoutException) {
newException = new TimeoutException(msg);
} else if (cause instanceof InvalidConfigurationException) {
newException = new InvalidConfigurationException(msg);
} else if (cause instanceof AuthenticationException) {
newException = new AuthenticationException(msg);
} else if (cause instanceof IncompatibleSchemaException) {
newException = new IncompatibleSchemaException(msg);
} else if (cause instanceof TooManyRequestsException) {
newException = new TooManyRequestsException(msg);
} else if (cause instanceof LookupException) {
newException = new LookupException(msg);
} else if (cause instanceof ConnectException) {
newException = new ConnectException(msg);
} else if (cause instanceof AlreadyClosedException) {
newException = new AlreadyClosedException(msg);
} else if (cause instanceof TopicTerminatedException) {
newException = new TopicTerminatedException(msg);
} else if (cause instanceof AuthorizationException) {
newException = new AuthorizationException(msg);
} else if (cause instanceof GettingAuthenticationDataException) {
newException = new GettingAuthenticationDataException(msg);
} else if (cause instanceof UnsupportedAuthenticationException) {
newException = new UnsupportedAuthenticationException(msg);
} else if (cause instanceof BrokerPersistenceException) {
newException = new BrokerPersistenceException(msg);
} else if (cause instanceof BrokerMetadataException) {
newException = new BrokerMetadataException(msg);
} else if (cause instanceof ProducerBusyException) {
newException = new ProducerBusyException(msg);
} else if (cause instanceof ConsumerBusyException) {
newException = new ConsumerBusyException(msg);
} else if (cause instanceof NotConnectedException) {
newException = new NotConnectedException();
} else if (cause instanceof InvalidMessageException) {
newException = new InvalidMessageException(msg);
} else if (cause instanceof InvalidTopicNameException) {
newException = new InvalidTopicNameException(msg);
} else if (cause instanceof NotSupportedException) {
newException = new NotSupportedException(msg);
} else if (cause instanceof NotAllowedException) {
newException = new NotAllowedException(msg);
} else if (cause instanceof ProducerQueueIsFullError) {
newException = new ProducerQueueIsFullError(msg);
} else if (cause instanceof ProducerBlockedQuotaExceededError) {
newException = new ProducerBlockedQuotaExceededError(msg);
} else if (cause instanceof ProducerBlockedQuotaExceededException) {
newException = new ProducerBlockedQuotaExceededException(msg);
} else if (cause instanceof ChecksumException) {
newException = new ChecksumException(msg);
} else if (cause instanceof CryptoException) {
newException = new CryptoException(msg);
} else if (cause instanceof ConsumerAssignException) {
newException = new ConsumerAssignException(msg);
} else if (cause instanceof MessageAcknowledgeException) {
newException = new MessageAcknowledgeException(msg);
} else if (cause instanceof TransactionConflictException) {
newException = new TransactionConflictException(msg);
} else if (cause instanceof TopicDoesNotExistException) {
newException = new TopicDoesNotExistException(msg);
} else if (cause instanceof SubscriptionNotFoundException) {
newException = new SubscriptionNotFoundException(msg);
} else if (cause instanceof ProducerFencedException) {
newException = new ProducerFencedException(msg);
} else if (cause instanceof MemoryBufferIsFullError) {
newException = new MemoryBufferIsFullError(msg);
} else if (cause instanceof NotFoundException) {
newException = new NotFoundException(msg);
} else if (cause instanceof TransactionHasOperationFailedException) {
newException = new TransactionHasOperationFailedException(msg);
} else {
newException = new PulsarClientException(t);
}
return newException;
}