Put simply, I have a piece of code that looks like this:
if some_condition_that_evals_to_True:
raise ValueError("Error message")
What I want to do is to insert a logging statement that logs this entire exception but doing it just this way only saves the logger message:
if some_condition_that_evals_to_True:
logger.error("Logged error message")
raise ValueError("Error message")
Any one know how to save the entire error message including the ValueError?
EDIT:
The following is what I am trying to recreate:
if some_condition_that_evals_to_True:
try:
raise ValueError("Error with value")
except ValueError:
logger.exception("Logging Error with Value")
raise
But this seems like a roundabout way to get the behavior I want, so another way to phrase my question: Is there a more elegant way get the same behavior as the above codeblock?