.. _wrong-exception-operation:

wrong-exception-operation / W0716
=================================

**Message emitted:**

Invalid exception operation. %s

**Description:**

*Used when an operation is done against an exception, but the operation is not valid for the exception in question. Usually emitted when having binary operations between exceptions in except handlers.*


**Correct code:**

.. literalinclude:: /data/messages/w/wrong-exception-operation/good.py
   :language: python

**Additional details:**

You can help us make the doc better `by contributing <https://github.com/PyCQA/pylint/issues/5953>`_ !


Created by the `exceptions <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/exceptions.py>`__ checker.