-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[ServiceBus] Connection error with unknown condition code to be ServiceBusConnectionError instead of ServiceBusError #15688
Copy link
Copy link
Closed
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.Service Busblocking-releaseBlocks releaseBlocks release
Milestone
Description
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
| 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 |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.Service Busblocking-releaseBlocks releaseBlocks release