-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ServiceBus] Improve AMQP Error handling (#16427)
* improve error handling * Update sdk/servicebus/azure-servicebus/CHANGELOG.md
- Loading branch information
1 parent
79d9f53
commit 591ccd5
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
sdk/servicebus/azure-servicebus/tests/livetest/test_errors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import logging | ||
|
||
from uamqp import errors as AMQPErrors, constants as AMQPConstants | ||
from azure.servicebus.exceptions import ( | ||
_create_servicebus_exception, | ||
ServiceBusConnectionError, | ||
ServiceBusError | ||
) | ||
|
||
|
||
def test_link_idle_timeout(): | ||
logger = logging.getLogger("testlogger") | ||
amqp_error = AMQPErrors.LinkDetach(AMQPConstants.ErrorCodes.LinkDetachForced, description="Details: AmqpMessageConsumer.IdleTimerExpired: Idle timeout: 00:10:00.") | ||
sb_error = _create_servicebus_exception(logger, amqp_error) | ||
assert isinstance(sb_error, ServiceBusConnectionError) | ||
assert sb_error._retryable | ||
assert sb_error._shutdown_handler | ||
|
||
|
||
def test_unknown_connection_error(): | ||
logger = logging.getLogger("testlogger") | ||
amqp_error = AMQPErrors.AMQPConnectionError(AMQPConstants.ErrorCodes.UnknownError) | ||
sb_error = _create_servicebus_exception(logger, amqp_error) | ||
assert isinstance(sb_error,ServiceBusConnectionError) | ||
assert sb_error._retryable | ||
assert sb_error._shutdown_handler | ||
|
||
amqp_error = AMQPErrors.AMQPError(AMQPConstants.ErrorCodes.UnknownError) | ||
sb_error = _create_servicebus_exception(logger, amqp_error) | ||
assert not isinstance(sb_error,ServiceBusConnectionError) | ||
assert isinstance(sb_error,ServiceBusError) | ||
assert not sb_error._retryable | ||
assert sb_error._shutdown_handler |