From 26ffef5978856a58883cc4d99642bee550ad3370 Mon Sep 17 00:00:00 2001 From: Dmitry Orlov Date: Wed, 13 Nov 2019 18:08:48 +0300 Subject: [PATCH] [fix] add ChannelInvalidStateError exceptions instead of RuntimeError --- aiormq/__init__.py | 2 ++ aiormq/channel.py | 2 +- aiormq/exceptions.py | 4 ++++ aiormq/version.py | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/aiormq/__init__.py b/aiormq/__init__.py index e58eec7..657d97d 100644 --- a/aiormq/__init__.py +++ b/aiormq/__init__.py @@ -11,6 +11,7 @@ AuthenticationError, ChannelAccessRefused, ChannelClosed, + ChannelInvalidStateError, ChannelLockedResource, ChannelNotFoundEntity, ChannelPreconditionFailed, @@ -52,6 +53,7 @@ 'Channel', 'ChannelAccessRefused', 'ChannelClosed', + 'ChannelInvalidStateError', 'ChannelLockedResource', 'ChannelNotFoundEntity', 'ChannelPreconditionFailed', diff --git a/aiormq/channel.py b/aiormq/channel.py index 93f2452..3e9df92 100644 --- a/aiormq/channel.py +++ b/aiormq/channel.py @@ -74,7 +74,7 @@ def __init__(self, connector, number, @property def lock(self): if self.is_closed: - raise RuntimeError('%r closed' % self) + raise exc.ChannelInvalidStateError('%r closed' % self) return self.__lock diff --git a/aiormq/exceptions.py b/aiormq/exceptions.py index 0855114..065adb2 100644 --- a/aiormq/exceptions.py +++ b/aiormq/exceptions.py @@ -164,3 +164,7 @@ def __init__(self, message: DeliveredMessage, frame: spec.Frame, *args): message.delivery.routing_key, *args ) + + +class ChannelInvalidStateError(RuntimeError): + pass diff --git a/aiormq/version.py b/aiormq/version.py index bf1ff81..ae88d2d 100644 --- a/aiormq/version.py +++ b/aiormq/version.py @@ -7,7 +7,7 @@ team_email = 'me@mosquito.su' -version_info = (3, 0, 1) +version_info = (3, 1, 0) __author__ = ", ".join("{} <{}>".format(*info) for info in author_info) __version__ = ".".join(map(str, version_info))