# Raising AnsibleError exceptions inside the run() method of LookupModule class does not work as expected

**URL:** <https://forum.ansible.com/t/raising-ansibleerror-exceptions-inside-the-run-method-of-lookupmodule-class-does-not-work-as-expected/16323>\
**Category:** Ansible Developer\
**Created:** [September 24, 2014, 4:15pm UTC](https://forum.ansible.com/t/raising-ansibleerror-exceptions-inside-the-run-method-of-lookupmodule-class-does-not-work-as-expected/16323 "2014-09-24T16:15:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 24, 2014, 4:15pm UTC](https://forum.ansible.com/t/raising-ansibleerror-exceptions-inside-the-run-method-of-lookupmodule-class-does-not-work-as-expected/16323/1 "2014-09-24T16:15:22Z")

</div>

Hi Petros,

We’d need to see code about what you are referring to to know whether this was a thing or not.

Thanks!

–Michael

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 24, 2014, 4:40pm UTC](https://forum.ansible.com/t/raising-ansibleerror-exceptions-inside-the-run-method-of-lookupmodule-class-does-not-work-as-expected/16323/2 "2014-09-24T16:40:16Z")

</div>

Oh inside a lookup plugin?

Yeah those catch exceptions because the variables in them can be very late-binding.

The question as to whether that needs to include AnsibleError and can be done better, possibly just at the Jinja2 level, may be up for revision.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 24, 2014, 7:02pm UTC](https://forum.ansible.com/t/raising-ansibleerror-exceptions-inside-the-run-method-of-lookupmodule-class-does-not-work-as-expected/16323/3 "2014-09-24T19:02:14Z")

</div>

Oh I’d agree.

The question is mostly of how they can catch issues with unbound variables and leave those unfiltered, but also still allow direct exception raising.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 5, 2014, 6:05pm UTC](https://forum.ansible.com/t/raising-ansibleerror-exceptions-inside-the-run-method-of-lookupmodule-class-does-not-work-as-expected/16323/4 "2014-10-05T18:05:33Z")

</div>

“BTW, I saw a ‘v2’ directory, which looks like the start of a rewrite?”

More or less. Some refactoring is going to be required in order to make ansible more easy to manage and adapt for new language features - and undo some of the damage of taking many thousand pull requests that have impacted coherency. We’re still finding our footing with what this specifically will look like, so I’d request people not get involved with that codebase until we indicate we’re ready.
