# Ansible 2.19 Exceptions handling

**URL:** <https://forum.ansible.com/t/ansible-2-19-exceptions-handling/45220>\
**Category:** Get Help\
**Created:** [January 30, 2026, 7:44am UTC](https://forum.ansible.com/t/ansible-2-19-exceptions-handling/45220 "2026-01-30T07:44:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ildjarn](https://avatars.discourse-cdn.com/v4/letter/i/8491ac/32.png) [@ildjarn](https://forum.ansible.com/u/ildjarn)\
**Post date:** [January 30, 2026, 7:44am UTC](https://forum.ansible.com/t/ansible-2-19-exceptions-handling/45220/1 "2026-01-30T07:44:31Z")

</div>

Am I interpreting this error message wrong or is this message going against Python best practices?

`Error while resolving value for 'zones': The lookup plugin 'openprovider_contacts' failed: exceptions must derive from BaseException Origin: /runner/project/joost/test.yml:11:16…`

From PEP-8 ([PEP 8 – Style Guide for Python Code | peps.python.org](https://peps.python.org/pep-0008/#programming-recommendations)):

> Derive exceptions from `Exception` rather than `BaseException` . Direct inheritance from `BaseException` is reserved for exceptions where catching them is almost always the wrong thing to do.

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 30, 2026, 4:17pm UTC](https://forum.ansible.com/t/ansible-2-19-exceptions-handling/45220/2 "2026-01-30T16:17:04Z")

</div>

The error message is saying that an exception was found that is **not** derived from `BaseException`. This is actually an error by Python itself, as you can see when you try:

```python
>>> raise 42
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    raise 42
TypeError: exceptions must derive from BaseException

```

Also the PEP you are quoting is about exception classes that code defines. The error message is about a failure to adhere to basic Python _requirements_ (that every exception must be derived from `BaseException`, which is also the case for every exception derived from `Exception`) by code (in this case, the `openprovider_contacts` lookup).
