<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Rethrowing Exceptions in C#</title>
	<atom:link href="http://winterdom.com/2002/09/rethrowingexceptionsinc/feed" rel="self" type="application/rss+xml" />
	<link>http://winterdom.com/2002/09/rethrowingexceptionsinc</link>
	<description>by dæmons be driven</description>
	<lastBuildDate>Tue, 16 Mar 2010 06:33:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Xander</title>
		<link>http://winterdom.com/2002/09/rethrowingexceptionsinc/comment-page-1#comment-1265</link>
		<dc:creator>Xander</dc:creator>
		<pubDate>Tue, 12 Jan 2010 15:57:43 +0000</pubDate>
		<guid isPermaLink="false">http://winterdom.com/2002/09/rethrowingexceptionsinc#comment-1265</guid>
		<description>To &quot;CS&quot; : Actually it did work for me in VS2005, that very code sample you posted reported the exception was thrown in Function3()... below is the stack trace from your example

StackTrace	&quot;   at RethrowExceptionTester.Program.Function3() in Program.cs:line 62\r\n   at RethrowExceptionTester.Program.Function2() in Program.cs:line 47\r\n   at RethrowExceptionTester.Program.Function1() in Program.cs:line 35\r\n   at RethrowExceptionTester.Program.Main(String[] args) in Program.cs:line 17&quot;</description>
		<content:encoded><![CDATA[<p>To &#8220;CS&#8221; : Actually it did work for me in VS2005, that very code sample you posted reported the exception was thrown in Function3()&#8230; below is the stack trace from your example</p>
<p>StackTrace	&#8221;   at RethrowExceptionTester.Program.Function3() in Program.cs:line 62\r\n   at RethrowExceptionTester.Program.Function2() in Program.cs:line 47\r\n   at RethrowExceptionTester.Program.Function1() in Program.cs:line 35\r\n   at RethrowExceptionTester.Program.Main(String[] args) in Program.cs:line 17&#8243;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Saboteur</title>
		<link>http://winterdom.com/2002/09/rethrowingexceptionsinc/comment-page-1#comment-1247</link>
		<dc:creator>Saboteur</dc:creator>
		<pubDate>Thu, 03 Dec 2009 12:31:32 +0000</pubDate>
		<guid isPermaLink="false">http://winterdom.com/2002/09/rethrowingexceptionsinc#comment-1247</guid>
		<description>Microsoft sucks.
More complicated solution to Exception handling and you can still sometimes loose stack :(</description>
		<content:encoded><![CDATA[<p>Microsoft sucks.<br />
More complicated solution to Exception handling and you can still sometimes loose stack <img src='http://winterdom.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://winterdom.com/2002/09/rethrowingexceptionsinc/comment-page-1#comment-1100</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Sat, 22 Aug 2009 01:13:24 +0000</pubDate>
		<guid isPermaLink="false">http://winterdom.com/2002/09/rethrowingexceptionsinc#comment-1100</guid>
		<description>Thanks.

You say a lot of people get this wrong... for me, it is because I am coming from Java.

In Java, rethrowing an exception with &quot;throw e;&quot; will keep the original stack trace. The stack information is added to the exception object only the first time it is thrown.</description>
		<content:encoded><![CDATA[<p>Thanks.</p>
<p>You say a lot of people get this wrong&#8230; for me, it is because I am coming from Java.</p>
<p>In Java, rethrowing an exception with &#8220;throw e;&#8221; will keep the original stack trace. The stack information is added to the exception object only the first time it is thrown.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: software developer</title>
		<link>http://winterdom.com/2002/09/rethrowingexceptionsinc/comment-page-1#comment-1080</link>
		<dc:creator>software developer</dc:creator>
		<pubDate>Tue, 11 Aug 2009 09:59:31 +0000</pubDate>
		<guid isPermaLink="false">http://winterdom.com/2002/09/rethrowingexceptionsinc#comment-1080</guid>
		<description>Cool,

But I thisnk it is better to write error message and detail te be able to under stand the error better

Thanks for writing</description>
		<content:encoded><![CDATA[<p>Cool,</p>
<p>But I thisnk it is better to write error message and detail te be able to under stand the error better</p>
<p>Thanks for writing</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rj</title>
		<link>http://winterdom.com/2002/09/rethrowingexceptionsinc/comment-page-1#comment-652</link>
		<dc:creator>Rj</dc:creator>
		<pubDate>Fri, 30 Mar 2007 13:41:46 +0000</pubDate>
		<guid isPermaLink="false">http://winterdom.com/2002/09/rethrowingexceptionsinc#comment-652</guid>
		<description>Didn&#039;t work for me.
</description>
		<content:encoded><![CDATA[<p>Didn&#8217;t work for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cs</title>
		<link>http://winterdom.com/2002/09/rethrowingexceptionsinc/comment-page-1#comment-651</link>
		<dc:creator>cs</dc:creator>
		<pubDate>Fri, 31 Oct 2003 16:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://winterdom.com/2002/09/rethrowingexceptionsinc#comment-651</guid>
		<description>&lt;p&gt;I agree with Ryan.  It does not work.  The stack trace will point to the first throw, not where the error was generated.&lt;/p&gt;
&lt;p&gt;Try the following:&lt;/p&gt;
&lt;p&gt;		/// &lt;br /&gt;
/// The main entry point for the application.&lt;br /&gt;
/// &lt;br /&gt;
[STAThread]&lt;br /&gt;
static void Main(string[] args)&lt;br /&gt;
{&lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
Function1();&lt;br /&gt;
}&lt;br /&gt;
catch (Exception ex)&lt;br /&gt;
{&lt;br /&gt;
Console.WriteLine (ex.ToString ());&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;			Console.ReadLine ();&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;		static void Function1 ()&lt;br /&gt;
{&lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
Function2 ();&lt;br /&gt;
}&lt;br /&gt;
catch (Exception)&lt;br /&gt;
{&lt;br /&gt;
throw;&lt;br /&gt;
}&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;		static void Function2 ()&lt;br /&gt;
{&lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
Function3 ();&lt;br /&gt;
}&lt;br /&gt;
catch (Exception)&lt;br /&gt;
{&lt;br /&gt;
throw;&lt;br /&gt;
}&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;		static void Function3 ()&lt;br /&gt;
{&lt;br /&gt;
int i = 0;&lt;br /&gt;
int j = 0;&lt;/p&gt;
&lt;p&gt;			try&lt;br /&gt;
{&lt;br /&gt;
Console.WriteLine ((i/j).ToString ());&lt;br /&gt;
}&lt;br /&gt;
catch (Exception)&lt;br /&gt;
{&lt;br /&gt;
throw;&lt;br /&gt;
}&lt;br /&gt;
}&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I agree with Ryan.  It does not work.  The stack trace will point to the first throw, not where the error was generated.</p>
<p>Try the following:</p>
<p>		/// <br />
/// The main entry point for the application.<br />
/// <br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
try<br />
{<br />
Function1();<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine (ex.ToString ());<br />
}</p>
<p>			Console.ReadLine ();<br />
}</p>
<p>		static void Function1 ()<br />
{<br />
try<br />
{<br />
Function2 ();<br />
}<br />
catch (Exception)<br />
{<br />
throw;<br />
}<br />
}</p>
<p>		static void Function2 ()<br />
{<br />
try<br />
{<br />
Function3 ();<br />
}<br />
catch (Exception)<br />
{<br />
throw;<br />
}<br />
}</p>
<p>		static void Function3 ()<br />
{<br />
int i = 0;<br />
int j = 0;</p>
<p>			try<br />
{<br />
Console.WriteLine ((i/j).ToString ());<br />
}<br />
catch (Exception)<br />
{<br />
throw;<br />
}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rsponaugle</title>
		<link>http://winterdom.com/2002/09/rethrowingexceptionsinc/comment-page-1#comment-650</link>
		<dc:creator>rsponaugle</dc:creator>
		<pubDate>Sun, 09 Mar 2003 16:40:20 +0000</pubDate>
		<guid isPermaLink="false">http://winterdom.com/2002/09/rethrowingexceptionsinc#comment-650</guid>
		<description>&lt;p&gt;Lanik, tomasr:  Works *very* well... :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Lanik, tomasr:  Works *very* well&#8230; <img src='http://winterdom.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lanik</title>
		<link>http://winterdom.com/2002/09/rethrowingexceptionsinc/comment-page-1#comment-649</link>
		<dc:creator>Lanik</dc:creator>
		<pubDate>Tue, 11 Feb 2003 13:48:32 +0000</pubDate>
		<guid isPermaLink="false">http://winterdom.com/2002/09/rethrowingexceptionsinc#comment-649</guid>
		<description>&lt;p&gt;Actually, this *does* work.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Actually, this *does* work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://winterdom.com/2002/09/rethrowingexceptionsinc/comment-page-1#comment-648</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Thu, 31 Oct 2002 12:42:37 +0000</pubDate>
		<guid isPermaLink="false">http://winterdom.com/2002/09/rethrowingexceptionsinc#comment-648</guid>
		<description>&lt;p&gt;But the problem is that if you actually tried this you&#039;d find it didn&#039;t work.  Try it out sometime and you will see that the code you use above will lose the stack trace information.  At least this is true with Visual Studio .NET and the .NET framework SP2.  If it&#039;s working for you maybe you could explain.  &lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>But the problem is that if you actually tried this you&#8217;d find it didn&#8217;t work.  Try it out sometime and you will see that the code you use above will lose the stack trace information.  At least this is true with Visual Studio .NET and the .NET framework SP2.  If it&#8217;s working for you maybe you could explain.  </p>
]]></content:encoded>
	</item>
</channel>
</rss>
