10
Mar
1

Catch the exception and throw it again

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".

Enjoyed reading this post?
Subscribe to the RSS feed and have all new posts delivered straight to you.
  • http://bloguay.com/cheapuggs215/2011/12/15/uggs-nevertheless/ uggs

    i have got both DTS and Dolby Surround home theather system at home and the sound is superb

Celadon theme by the Themes Boutique
teeth bleaching
baldness treatment