<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ankit Jain &#187; csharp</title>
	<atom:link href="http://ankitjain.info/ankit/tag/csharp/feed/" rel="self" type="application/rss+xml" />
	<link>http://ankitjain.info/ankit</link>
	<description>» It’s all about Ankit and Web! «</description>
	<lastBuildDate>Thu, 02 Jun 2011 16:54:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Eating Exceptions&#8230; eeehhhh!</title>
		<link>http://ankitjain.info/ankit/2008/04/24/csharp-eat-exception-try/</link>
		<comments>http://ankitjain.info/ankit/2008/04/24/csharp-eat-exception-try/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 08:03:19 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Coding Guidelines]]></category>
		<category><![CDATA[Programming/Code]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[exception]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/2008/04/24/csharp-eat-exception-try</guid>
		<description><![CDATA[Following are few points you need to take care when you decide to eat an exception. These are very much specific to C# language. a. Limit the code block. Attempt to wrap one or two statements within try. b. If an exception is eaten, log details to some logging mechanism. In short never write empty [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoListParagraphCxSpMiddle">Following are few points you need to take care when you decide to eat an exception. These are very much specific to C# language.</p>
<p style="margin-left: 1in; text-indent: -0.25in" class="MsoListParagraphCxSpMiddle">a.<span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal">       </span>Limit the code block. Attempt  to wrap one or two statements within <span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New'">try</span>.</p>
<p style="margin-left: 1in; text-indent: -0.25in" class="MsoListParagraphCxSpMiddle">b.<span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal">      </span>If an exception is eaten, log  details to some logging mechanism. In short never write empty catch <span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New'">catch</span><span style="font-size: 10pt; line-height: 115%; font-family: 'Courier New'">(</span><span style="color: #2b91af">Exception</span>) {}.</p>
<p style="margin-left: 1in; text-indent: -0.25in" class="MsoListParagraphCxSpMiddle">c.<span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal">       </span>Never eat exception that  indicates some bad behavior of code execution like &#8211; <span style="font-size: 10pt; color: #2b91af; line-height: 115%; font-family: 'Courier New'">ArgumentNullException</span>,</p>
<p style="margin-left: 1in" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10pt; color: #2b91af; line-height: 115%; font-family: 'Courier New'">NullReferenceException</span>,</p>
<p style="margin-left: 1in" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10pt; color: #2b91af; line-height: 115%; font-family: 'Courier New'">ArgumentNullException</span>,</p>
<p style="margin-left: 1in" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10pt; color: #2b91af; line-height: 115%; font-family: 'Courier New'">InvalidCastException</span>,</p>
<p style="margin-left: 1in" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10pt; color: #2b91af; line-height: 115%; font-family: 'Courier New'">InvalidOperationException</span>,</p>
<p style="margin-left: 1in" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10pt; color: #2b91af; line-height: 115%; font-family: 'Courier New'">AccessViolationException</span>,  etc;</p>
<p style="margin-left: 1in; text-indent: -0.25in" class="MsoListParagraphCxSpMiddle">d.<span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal">      </span>There is <a target="_blank" href="http://msdn2.microsoft.com/en-us/library/aa664760(VS.71).aspx">a big  difference between</a> <span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New'">throw</span>  and <span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New'">throw  </span><span style="font-size: 10pt; line-height: 115%; font-family: 'Courier New'">exeception</span> statements.  <a target="_blank" href="http://www.winterdom.com/weblog/PermaLink,guid,154.aspx">This is in  terms of resetting stack trace which the later does.</a> If you are writing a  framework or want to hide your internal implementation use <span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New'">throw  </span><span style="font-size: 10pt; line-height: 115%; font-family: 'Courier New'">exception</span>,  otherwise use <span style="font-size: 10pt; color: blue; line-height: 115%; font-family: 'Courier New'">throw</span> only.</p>
<p>- Ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2008/04/24/csharp-eat-exception-try/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

