use of `raise Exception`
See original GitHub issueWithin tenant.py
we use raise Exception
and I wonder if this is needed in all cases.
For example we may see the following:
1552982503.81 - keylime.cloudverifier - WARNING - Node of uuid D432FBB3-D2F1-4A97-9EF7-75BD81C00000 already exists
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/keylime-1.2-py2.7.egg/keylime/tenant.py", line 744, in main
mytenant.do_cv()
File "/usr/lib/python2.7/site-packages/keylime-1.2-py2.7.egg/keylime/tenant.py", line 481, in do_cv
raise Exception("Node %s already existed at CV. Please use delete or update."%self.node_uuid)
Exception: Node D432FBB3-D2F1-4A97-9EF7-75BD81C00000 already existed at CV. Please use delete or update.
The use of raise Exception
here makes it look like the code is broken as we get a traceback as CLI output, but in fact the code has captured the condition correctly and could instead report with the logger (most likely logger.info
)
If we have agreement here on using the logger instead of raise Exception
. I am happy to work on a PR that we can then review.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Python Raise an Exception - W3Schools
As a Python developer you can choose to throw an exception if a condition occurs. To throw (or raise) an exception, use the...
Read more >8. Errors and Exceptions — Python 3.11.1 documentation
When an exception is created in order to be raised, it is usually initialized with information that describes the error that has occurred....
Read more >Manually raising (throwing) an exception in Python
The raise statement without any arguments re-raises the last exception. This is useful if you need to perform some actions after catching the...
Read more >Raising Exceptions | Engineering Education (EngEd) Program
This article will go over how to manually throw exceptions in Python and use assertions for better debugging. Raising exceptions allows us ...
Read more >Python Raise Exceptions
Python Raise Exception · raise ExceptionType() · try: raise ValueError('The value error exception', 'x', 'y') except ValueError as ex: print(ex. · ('The value ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
there’s a lot of duplicate log.error and raise Exception pairs that could be deduplicated
@jetwhiz there’s nothing in the webapp that relies upon exceptions right?