Right now, if there's a connection error happening with condition unknown, a ServiceBusError is throwed due to the current condition based exception handling -- condition code b"amqp:unknown-error" is not in the condition-error mapping and default to ServiceBusError.
However, I think this could be improved by raising ServiceBusConnectionError if the error condition is unknown to be more detailed.
This is a non-breaking change.
To be more specific, it's this part of the code that should be improved:
|
def _handle_amqp_exception_with_condition( |
|
logger, |
|
condition, |
|
description, |
|
exception=None, |
|
status_code=None |
|
): |
|
# |
|
# handling AMQP Errors that have the condition field or the mgmt handler |
|
logger.info("AMQP error occurred: (%r), condition: (%r), description: (%r).", exception, condition, description) |
|
if condition == AMQPErrorCodes.NotFound: |
|
# handle NotFound error code |
|
error_cls = ServiceBusCommunicationError \ |
|
if isinstance(exception, AMQPErrors.AMQPConnectionError) else MessagingEntityNotFoundError |
|
elif condition == AMQPErrorCodes.ClientError and 'timed out' in str(exception): |
|
# handle send timeout |
|
error_cls = OperationTimeoutError |
|
else: |
|
# handle other error codes |
|
error_cls = _ERROR_CODE_TO_ERROR_MAPPING.get(condition, ServiceBusError) |
|
|
|
error = error_cls(message=description, error=exception, condition=condition, status_code=status_code) |
|
if condition in _NO_RETRY_CONDITION_ERROR_CODES: |
|
error._retryable = False # pylint: disable=protected-access |
|
|
|
return error |
Right now, if there's a connection error happening with condition unknown, a ServiceBusError is throwed due to the current condition based exception handling -- condition code b"amqp:unknown-error" is not in the condition-error mapping and default to ServiceBusError.
However, I think this could be improved by raising ServiceBusConnectionError if the error condition is unknown to be more detailed.
This is a non-breaking change.
To be more specific, it's this part of the code that should be improved:
azure-sdk-for-python/sdk/servicebus/azure-servicebus/azure/servicebus/exceptions.py
Lines 83 to 108 in 21e154b