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

* file lookup now works with general lookup error framework

(cherry picked from commit 3448fcabc5)

Co-authored-by: Brian Coca <bcoca@users.noreply.github.com>
pull/79444/head
Gaudenz Steinlin 2 years ago committed by GitHub
parent fd63b2f306
commit 5f6537b644
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