Skip to content

Commit c9040d7

Browse files
authored
Don't just raise AnsibleError with the exception message (ansible#49654)
* Don't just raise AnsibleError with the exception message. Fixes ansible#49252 * Add changelog fragment
1 parent f7c44aa commit c9040d7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- vault - Improve error messages encountered when reading vault files (https://github.com/ansible/ansible/issues/49252)

lib/ansible/parsing/vault/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,10 @@ def read_data(self, filename):
10301030
with open(filename, "rb") as fh:
10311031
data = fh.read()
10321032
except Exception as e:
1033-
raise AnsibleError(to_native(e))
1033+
msg = to_native(e)
1034+
if not msg:
1035+
msg = repr(e)
1036+
raise AnsibleError('Unable to read source file (%s): %s' % (to_native(filename), msg))
10341037

10351038
return data
10361039

0 commit comments

Comments
 (0)