PYTHON-739 - Add namespace to command failure message.
This commit is contained in:
parent
1e4b0c5a12
commit
70aaf0dc52
@ -348,7 +348,8 @@ class Database(common.BaseObject):
|
||||
result = doc
|
||||
|
||||
if check:
|
||||
msg = "command %s failed: %%s" % repr(command).replace("%", "%%")
|
||||
msg = "command %s on namespace %s failed: %%s" % (
|
||||
repr(command).replace("%", "%%"), self.name + '.$cmd')
|
||||
helpers._check_command_response(result, self.connection.disconnect,
|
||||
msg, allowable_errors)
|
||||
|
||||
|
||||
@ -675,7 +675,8 @@ class MongoClient(common.BaseObject):
|
||||
def __simple_command(self, sock_info, dbname, spec):
|
||||
"""Send a command to the server. May raise AutoReconnect.
|
||||
"""
|
||||
rqst_id, msg, _ = message.query(0, dbname + '.$cmd', 0, -1, spec)
|
||||
ns = dbname + '.$cmd'
|
||||
rqst_id, msg, _ = message.query(0, ns, 0, -1, spec)
|
||||
start = time.time()
|
||||
try:
|
||||
sock_info.sock.sendall(msg)
|
||||
@ -689,7 +690,8 @@ class MongoClient(common.BaseObject):
|
||||
|
||||
end = time.time()
|
||||
response = helpers._unpack_response(response)['data'][0]
|
||||
msg = "command %s failed: %%s" % repr(spec).replace("%", "%%")
|
||||
msg = "command %s on namespace %s failed: %%s" % (
|
||||
repr(spec).replace("%", "%%"), ns)
|
||||
helpers._check_command_response(response, None, msg)
|
||||
return response, end - start
|
||||
|
||||
|
||||
@ -1011,7 +1011,8 @@ class MongoReplicaSetClient(common.BaseObject):
|
||||
"""Send a command to the server.
|
||||
Returns (response, ping_time in seconds).
|
||||
"""
|
||||
rqst_id, msg, _ = message.query(0, dbname + '.$cmd', 0, -1, spec)
|
||||
ns = dbname + '.$cmd'
|
||||
rqst_id, msg, _ = message.query(0, ns, 0, -1, spec)
|
||||
start = time.time()
|
||||
try:
|
||||
sock_info.sock.sendall(msg)
|
||||
@ -1022,7 +1023,8 @@ class MongoReplicaSetClient(common.BaseObject):
|
||||
|
||||
end = time.time()
|
||||
response = helpers._unpack_response(response)['data'][0]
|
||||
msg = "command %s failed: %%s" % repr(spec).replace("%", "%%")
|
||||
msg = "command %s on namespace %s failed: %%s" % (
|
||||
repr(spec).replace("%", "%%"), ns)
|
||||
helpers._check_command_response(response, None, msg)
|
||||
return response, end - start
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user