Same behavior in Python and C#…
Wrong code:
try:
# some code
except Exception, e:
# log the exception or whatever
raise e
Right code:
try:
# some code
except Exception, e:
# log the exception or whatever
raise # JUST RAISE!!!
Wrong code:
try
{
// whatever
}
catch (Exception e)
{
// log the exception or whatever
throw e
}
Right:
try
{
// whatever
}
catch (Exception e)
{
// log the exception or whatever
throw // JUST THROW!!!
}
Reason: Exception stacktrace is lost if you write “raise e” or “throw e” instead of just “raise” or “throw”.