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#?
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
Post a Comment