Skip to content

Commit 219193a

Browse files
authored
add details about catching all exceptions (#213)
* add details about catching all exceptions * Small grammar/wording changes
1 parent 42fec67 commit 219193a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

exceptions.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ trapping ALL exceptions:
6262
# Some logging if you want
6363
raise e
6464
65-
This can be helpful when you have no idea about the exceptions which may
66-
be thrown by your program.
65+
This can be helpful when you have no idea about the exceptions that may
66+
be thrown by your program. If you are just looking to catch all execptions,
67+
but don't actually care about what they are, you can even exclude the
68+
``Exception as e`` part.
69+
70+
Note:: catching all exceptions may have unintended consequences because catching
71+
all exceptions may also catch the ones you want to occur; for example, in
72+
many command-line based programs, pressing control+c will terminate the program,
73+
but if you catch all excepts, the ``KeyboardInterrupt`` will be caught as an
74+
exception, so pressing control+c will NOT terminate the program.
6775

6876
``finally`` clause
6977
~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)
close