question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

use of `raise Exception`

See original GitHub issue

Within 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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nabilschearcommented, Mar 19, 2019

there’s a lot of duplicate log.error and raise Exception pairs that could be deduplicated

0reactions
nabilschearcommented, Mar 19, 2019

@jetwhiz there’s nothing in the webapp that relies upon exceptions right?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found