-
-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] Adding exception section for good practice #252
[IMP] Adding exception section for good practice #252
Conversation
try: | ||
sentences | ||
except: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove pass
If you use a sentence after pass then is not need it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment but otherwise 👍
If you really need to use the `pass` consider logging that exception | ||
|
||
```python | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to reduce the indentation level by one, this is double indented in the example block right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thanks for your comment!
@lmignon Are you agree with this guideline (and future check)? |
@yajo @pedrobaeza Your feedback is welcome |
In some cases It could be useful to properly log the exception with the stacktrace.. (That depends of the context.) try:
sentences
except:
_logger.debug('Why the exception is safe....', exc_info=1)) |
try: | ||
sentences | ||
except: | ||
_logger.debug('Pass') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please switch to a lowercase L. _logger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand, what uppercase L are you referring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! dont worry
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a auto-translator enabled from your browser?
@JesusZapata |
@moylop260 @lmignon Done! |
@moylop260 |
The
pass
into block except is not a good practice!By including the
pass
we assume that our algorithm can continue to function after the exception occurredIf you really need to use the
pass
consider logging that exception