Skip to content

Commit 49d685b

Browse files
jpastuszukyasoob
authored andcommitted
Update exceptions.rst (yasoob#183)
It is always better to catch exception and raise it with a detailed information, difference between just raising and raising caught exception. With rising e: .. code:: python Traceback (most recent call last): File "<stdin>", line 5, in <module> File "<stdin>", line 2, in <module> FileNotFoundError: [Errno 2] No such file or directory: 'test' Just rising: .. code:: python Traceback (most recent call last): File "<stdin>", line 2, in <module> FileNotFoundError: [Errno 2] No such file or directory: 'test'
1 parent 6d47c66 commit 49d685b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

exceptions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ trapping ALL exceptions:
5656
5757
try:
5858
file = open('test.txt', 'rb')
59-
except Exception:
59+
except Exception as e:
6060
# Some logging if you want
61-
raise
61+
raise e
6262
6363
This can be helpful when you have no idea about the exceptions which may
6464
be thrown by your program.

0 commit comments

Comments
 (0)