Skip to content

Commit

Permalink
Simplified error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
eandersson committed Sep 7, 2021
1 parent 0875d34 commit be2f5ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion amqpstorm/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def check_for_errors(self,):
self.check_for_exceptions()

if self.is_closed:
raise AMQPChannelError('channel was closed')
raise AMQPChannelError('channel closed')

def check_for_exceptions(self):
"""Check channel for exceptions.
Expand Down
6 changes: 3 additions & 3 deletions amqpstorm/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def channel(self, rpc_timeout=60, lazy=False):
if not compatibility.is_integer(rpc_timeout):
raise AMQPInvalidArgument('rpc_timeout should be an integer')
elif self.is_closed:
raise AMQPConnectionError('socket/connection closed')
raise AMQPConnectionError('connection closed')

with self.lock:
channel_id = self._get_next_available_channel_id()
Expand All @@ -202,7 +202,7 @@ def check_for_errors(self):
if not self.exceptions:
if not self.is_closed:
return
why = AMQPConnectionError('connection was closed')
why = AMQPConnectionError('connection closed')
self.exceptions.append(why)
self.set_state(self.CLOSED)
self.close()
Expand Down Expand Up @@ -402,5 +402,5 @@ def _wait_for_connection_state(self, state=Stateful.OPEN, rpc_timeout=30):
while self.current_state != state:
self.check_for_errors()
if time.time() - start_time > rpc_timeout:
raise AMQPConnectionError('Connection timed out')
raise AMQPConnectionError('connection timed out')
sleep(IDLE_WAIT)
2 changes: 1 addition & 1 deletion amqpstorm/tests/functional/management/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ def test_api_connection_close(self):

self.assertTrue(connection_found)
self.assertRaisesRegex(
AMQPConnectionError, 'socket/connection closed',
AMQPConnectionError, 'connection closed',
connection.channel, 1
)
8 changes: 4 additions & 4 deletions amqpstorm/tests/unit/channel/test_channel_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_channel_check_error_when_closed(self):

self.assertRaisesRegex(
exception.AMQPChannelError,
'channel was closed',
'channel closed',
channel.check_for_errors
)

Expand All @@ -66,7 +66,7 @@ def test_channel_check_error_connection_closed(self):

self.assertRaisesRegex(
exception.AMQPConnectionError,
'connection was closed',
'connection closed',
channel.check_for_errors
)

Expand All @@ -77,7 +77,7 @@ def test_channel_raises_when_closed(self):
self.assertFalse(channel.is_open)
self.assertRaisesRegex(
exception.AMQPChannelError,
'channel was closed',
'channel closed',
channel.check_for_errors
)
self.assertTrue(channel.is_closed)
Expand All @@ -89,7 +89,7 @@ def test_channel_closed_after_connection_closed(self):
self.assertTrue(channel.is_open)
self.assertRaisesRegex(
exception.AMQPConnectionError,
'connection was closed',
'connection closed',
channel.check_for_errors
)
self.assertTrue(channel.is_closed)
Expand Down

0 comments on commit be2f5ca

Please sign in to comment.