unique error messages to avoid confusion

pull/19581/head
Brian Coca 8 years ago
parent ab560df15f
commit ebf835045f

@ -2051,8 +2051,7 @@ class AnsibleModule(object):
native_suffix = os.path.basename(b_dest) native_suffix = os.path.basename(b_dest)
native_prefix = b('.ansible_tmp') native_prefix = b('.ansible_tmp')
try: try:
tmp_dest_fd, tmp_dest_name = tempfile.mkstemp( tmp_dest_fd, tmp_dest_name = tempfile.mkstemp( prefix=native_prefix, dir=native_dest_dir, suffix=native_suffix)
prefix=native_prefix, dir=native_dest_dir, suffix=native_suffix)
except (OSError, IOError): except (OSError, IOError):
e = get_exception() e = get_exception()
self.fail_json(msg='The destination directory (%s) is not writable by the current user. Error was: %s' % (os.path.dirname(dest), e)) self.fail_json(msg='The destination directory (%s) is not writable by the current user. Error was: %s' % (os.path.dirname(dest), e))
@ -2095,10 +2094,10 @@ class AnsibleModule(object):
if unsafe_writes: if unsafe_writes:
self._unsafe_writes(b_tmp_dest_name, b_dest, e) self._unsafe_writes(b_tmp_dest_name, b_dest, e)
else: else:
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, e)) self.fail_json(msg='Unable to rename file: %s to %s: %s' % (src, dest, e))
except (shutil.Error, OSError, IOError): except (shutil.Error, OSError, IOError):
e = get_exception() e = get_exception()
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, e)) self.fail_json(msg='Failed to replace file: %s to %s: %s' % (src, dest, e))
finally: finally:
self.cleanup(b_tmp_dest_name) self.cleanup(b_tmp_dest_name)

Loading…
Cancel
Save