Skip to content

Update exceptions.rst#183

Merged
yasoob merged 1 commit into
yasoob:masterfrom
jpastuszuk:patch-3
Nov 30, 2018
Merged

Update exceptions.rst#183
yasoob merged 1 commit into
yasoob:masterfrom
jpastuszuk:patch-3

Conversation

@jpastuszuk
Copy link
Copy Markdown
Contributor

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:

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:

Traceback (most recent call last):
       File "<stdin>", line 2, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'test'

raising exception with instance of exception gives us more information for example where exception was raised finally

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'
@yasoob yasoob merged commit 49d685b into yasoob:master Nov 30, 2018
@jpastuszuk jpastuszuk deleted the patch-3 branch November 30, 2018 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants