Skip to content

Commit 8bfe43f

Browse files
committed
Use the format spec for exceptions as strings
1 parent 91c0ab9 commit 8bfe43f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

rabbitpy/exceptions.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ConnectionException(RabbitpyException):
4040
4141
"""
4242
def __str__(self):
43-
return 'Unable to connect to the remote server %r' % self.args
43+
return 'Unable to connect to the remote server {}'.format(self.args)
4444

4545

4646
class ConnectionResetException(RabbitpyException):
@@ -65,8 +65,8 @@ class RemoteClosedChannelException(RabbitpyException):
6565
6666
"""
6767
def __str__(self):
68-
return 'Channel %i was closed by the remote server (%i): %s' % \
69-
(self.args[0], self.args[1], self.args[2])
68+
return 'Channel {} was closed by the remote server ({}): {}'.format(
69+
*self.args)
7070

7171

7272
class RemoteClosedException(RabbitpyException):
@@ -75,8 +75,8 @@ class RemoteClosedException(RabbitpyException):
7575
7676
"""
7777
def __str__(self):
78-
return 'Connection was closed by the remote server (%i): %s' % \
79-
(self.args[0], self.args[1])
78+
return 'Connection was closed by the remote server ({}): {}'.format(
79+
*self.args)
8080

8181

8282
class MessageReturnedException(RabbitpyException):
@@ -85,8 +85,8 @@ class MessageReturnedException(RabbitpyException):
8585
8686
"""
8787
def __str__(self):
88-
return 'Message was returned by RabbitMQ: (%s) %s for exchange %s' % \
89-
(self.args[0], self.args[1], self.args[2])
88+
return 'Message was returned by RabbitMQ: ({}) for exchange {}'.format(
89+
*self.args)
9090

9191

9292
class NoActiveTransactionError(RabbitpyException):
@@ -113,7 +113,7 @@ class NotSupportedError(RabbitpyException):
113113
114114
"""
115115
def __str__(self):
116-
return 'The selected feature "%s" is not supported' % self.args[0]
116+
return 'The selected feature "{}" is not supported'.format(self.args)
117117

118118

119119
class TooManyChannelsError(RabbitpyException):
@@ -134,8 +134,8 @@ class UnexpectedResponseError(RabbitpyException):
134134
135135
"""
136136
def __str__(self):
137-
return 'Received an expected response, expected %s, received %s' % \
138-
(self.args[0], self.args[1])
137+
return 'Received an expected response, expected {}, ' \
138+
'received {}'.format(*self.args)
139139

140140

141141
# AMQP Exceptions

0 commit comments

Comments
 (0)