<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>[C#] Properly Re-throwing Exceptions in C# (or .NET to be General)   </title><link>http://blogs.msdn.com/b/tfang/archive/2012/09/14/c-properly-re-throwing-exceptions-in-c-or-net-to-be-general.aspx</link><description>If you've spent almost your entire college with Java and recently become a newbie to .NET and C# like me, you will probably the same question I asked myself today sooner or later (better sooner...): How to properly re-throw an exception in C#, and is</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: [C#] Properly Re-throwing Exceptions in C# (or .NET to be General)   </title><link>http://blogs.msdn.com/b/tfang/archive/2012/09/14/c-properly-re-throwing-exceptions-in-c-or-net-to-be-general.aspx#10350116</link><pubDate>Mon, 17 Sep 2012 14:50:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10350116</guid><dc:creator>João Angelo</dc:creator><description>&lt;p&gt;There is one subtle difference between &amp;quot;throw;&amp;quot; and &amp;quot;throw new Exception(&amp;quot;Wrap&amp;quot;, e);&amp;quot;.&lt;/p&gt;
&lt;p&gt;When using &amp;quot;throw;&amp;quot; the exception target site (line number on the stacktrace) on the method that rethrows the exception will be replaced by the line number of the &amp;quot;throw;&amp;quot; statement and the line number where the exception was originally thrown is lost. This does not happen if you throw a new exception that wraps the original one, so this option is the one that guarantees that no information is lost.&lt;/p&gt;
&lt;p&gt;Of course most of the times the fact that &amp;quot;throw;&amp;quot; maintains the full stacktrace is sufficient, but nonetheless is something to keep in mind.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10350116" width="1" height="1"&gt;</description></item></channel></rss>