Repository: MechanicalSoup/MechanicalSoup

Issue:
LinkNotFoundError should not inherit from BaseException
Hello,

I have code that performs many tests, reporting which tests failed. We therefore implement a try-catch such as

```python
try:
    run_test()
except Exception:
    msg = traceback.format_exc() 
    report_failure()
```

LinkNotFoundError is not caught by this because it inherits from BaseException.

Inheriting from BaseException is not recommended in the docs: https://docs.python.org/3/library/exceptions.html

I'd like too see this change, or if there is a reason for it I'm curious to hear it.

Discussion:

Patch:
diff --git a/docs/ChangeLog.rst b/docs/ChangeLog.rst
index 787e4bb..faa9109 100644
--- a/docs/ChangeLog.rst
+++ b/docs/ChangeLog.rst
@@ -5,6 +5,16 @@ Release Notes
 Version 1.0 (in development)
 ============================
 
+Bug fixes
+---------
+
+* **Breaking Change:** :class:`~mechanicalsoup.LinkNotFoundError` now derives
+  from ``Exception`` instead of ``BaseException``. While this will bring the
+  behavior in line with most people's expectations, it may affect the behavior
+  of your code if you were heavily relying on this implementation detail in
+  your exception handling.
+  [`#203 <https://github.com/MechanicalSoup/MechanicalSoup/issues/203>`__]
+
 Version 0.10
 ============
 
diff --git a/mechanicalsoup/utils.py b/mechanicalsoup/utils.py
index 740b35e..9ad7ff0 100644
--- a/mechanicalsoup/utils.py
+++ b/mechanicalsoup/utils.py
@@ -1,4 +1,4 @@
-class LinkNotFoundError(BaseException):
+class LinkNotFoundError(Exception):
     """Exception raised when mechanicalsoup fails to find something.
 
     This happens in situations like (non-exhaustive list):


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
new file mode 100644
index 0000000..2400fcb
--- /dev/null
+++ b/tests/test_utils.py
@@ -0,0 +1,9 @@
+import mechanicalsoup
+import pytest
+
+
+def test_LinkNotFoundError():
+    with pytest.raises(mechanicalsoup.LinkNotFoundError):
+        raise mechanicalsoup.utils.LinkNotFoundError
+    with pytest.raises(Exception):
+        raise mechanicalsoup.utils.LinkNotFoundError