c# - Throwing an exception in a catch section -


i've got new project. every time dealing else code it's adventure.

here found:

try {    ..... } catch (invalidoperationexception e) {     throw e; } catch (exception e) {     throw; } 

anybody has idea why?

ps everybody. helps. here sources recommended:

why catch , rethrow exception in c#?

http://msdn.microsoft.com/en-us/library/0yd65esw.aspx

http://msdn.microsoft.com/en-us/library/ms229005.aspx

the real danger of (other being useless...) modifies call stack. others have briefly mentioned in comments, deserves called out specifically.

when have throw ex;, previous call stack blown away , replaced call stack @ point throw ex; called. never want this. catch exception, log it, rethrow exception. when doing that, want use throw;. preserve original stack trace.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -