file lookup now works with general lookup error framework (#79339)

* file lookup now works with general lookup error framework
pull/79382/head
Brian Coca 2 years ago committed by GitHub
parent 35db7df9ce
commit 3448fcabc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- file lookup now plays nice with generic lookup ``errors`` option.

@ -50,7 +50,7 @@ RETURN = """
elements: str
"""
from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleLookupError
from ansible.plugins.lookup import LookupBase
from ansible.module_utils._text import to_text
from ansible.utils.display import Display
@ -81,8 +81,8 @@ class LookupModule(LookupBase):
ret.append(contents)
else:
# TODO: only add search info if abs path?
raise AnsibleError("file not found, use -vvvvv to see paths searched")
raise AnsibleOptionsError("file not found, use -vvvvv to see paths searched")
except AnsibleError as e:
raise AnsibleOptionsError("The 'file' lookup had an issue accessing the file '%s'" % term, orig_exc=e)
raise AnsibleLookupError("The 'file' lookup had an issue accessing the file '%s'" % term, orig_exc=e)
return ret

Loading…
Cancel
Save