summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--network/basics/get_url.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/network/basics/get_url.py b/network/basics/get_url.py
index c59161f5..9cb55560 100644
--- a/network/basics/get_url.py
+++ b/network/basics/get_url.py
@@ -206,10 +206,14 @@ def url_get(module, url, dest, use_proxy, last_mod_time, force, timeout=10, head
if info['status'] == 304:
module.exit_json(url=url, dest=dest, changed=False, msg=info.get('msg', ''))
- # create a temporary file and copy content to do checksum-based replacement
+ # Exceptions in fetch_url may result in a status -1, the ensures a proper error to the user in all cases
+ if info['status'] == -1:
+ module.fail_json(msg=info['msg'], url=url, dest=dest)
+
if info['status'] != 200 and not url.startswith('file:/') and not (url.startswith('ftp:/') and info.get('msg', '').startswith('OK')):
module.fail_json(msg="Request failed", status_code=info['status'], response=info['msg'], url=url, dest=dest)
+ # create a temporary file and copy content to do checksum-based replacement
if tmp_dest != '':
# tmp_dest should be an existing dir
tmp_dest_is_dir = os.path.isdir(tmp_dest)