summaryrefslogtreecommitdiff
path: root/doc/user_guide
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2023-01-24 09:50:36 +0100
committerGitHub <noreply@github.com>2023-01-24 09:50:36 +0100
commitbd3bcb1b774853d97d182f6c869a627264739e90 (patch)
tree9f29c972c21b2aaf8d79fa0282b101a5e77399c6 /doc/user_guide
parentbf39dbd8381041963278fae3f9eb216011024bee (diff)
downloadpylint-git-bd3bcb1b774853d97d182f6c869a627264739e90.tar.gz
[doc] Add details and related links for bare/broad-except (#8077)
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'doc/user_guide')
-rw-r--r--doc/user_guide/checkers/features.rst17
1 files changed, 13 insertions, 4 deletions
diff --git a/doc/user_guide/checkers/features.rst b/doc/user_guide/checkers/features.rst
index da802069c..fa5d0f8bd 100644
--- a/doc/user_guide/checkers/features.rst
+++ b/doc/user_guide/checkers/features.rst
@@ -447,8 +447,9 @@ Exceptions checker Messages
Used when an except catches a type that was already caught by a previous
handler.
:broad-exception-caught (W0718): *Catching too general exception %s*
- Used when an except catches a too general exception, possibly burying
- unrelated errors.
+ If you use a naked ``except Exception:`` clause, you might end up catching
+ exceptions other than the ones you expect to catch. This can hide bugs or
+ make it harder to debug programs when unrelated errors are hidden.
:raise-missing-from (W0707): *Consider explicitly re-raising using %s'%s from %s'*
Python's exception chaining shows the traceback of the current exception, but
also of the original exception. When you raise a new exception after another
@@ -467,9 +468,17 @@ Exceptions checker Messages
valid for the exception in question. Usually emitted when having binary
operations between exceptions in except handlers.
:bare-except (W0702): *No exception type(s) specified*
- Used when an except clause doesn't specify exceptions type to catch.
+ A bare ``except:`` clause will catch ``SystemExit`` and ``KeyboardInterrupt``
+ exceptions, making it harder to interrupt a program with ``Control-C``, and
+ can disguise other problems. If you want to catch all exceptions that signal
+ program errors, use ``except Exception:`` (bare except is equivalent to
+ ``except BaseException:``).
:broad-exception-raised (W0719): *Raising too general exception: %s*
- Used when an except raises a too general exception.
+ Raising exceptions that are too generic force you to catch exception
+ generically too. It will force you to use a naked ``except Exception:``
+ clause. You might then end up catching exceptions other than the ones you
+ expect to catch. This can hide bugs or make it harder to debug programs when
+ unrelated errors are hidden.
:try-except-raise (W0706): *The except handler raises immediately*
Used when an except handler uses raise as its first or only operator. This is
useless because it raises back the exception immediately. Remove the raise