<?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: Don&#8217;t catch exceptions if you are not going to handle them</title>
	<atom:link href="http://www.diovo.com/2008/11/dont-catch-exceptions-if-you-are-not-going-to-handle-them/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.diovo.com/2008/11/dont-catch-exceptions-if-you-are-not-going-to-handle-them/</link>
	<description></description>
	<lastBuildDate>Wed, 10 Mar 2010 16:08:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Veera</title>
		<link>http://www.diovo.com/2008/11/dont-catch-exceptions-if-you-are-not-going-to-handle-them/comment-page-1/#comment-1130</link>
		<dc:creator>Veera</dc:creator>
		<pubDate>Sun, 16 Nov 2008 16:18:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=330#comment-1130</guid>
		<description>&lt;blockquote&gt;Exception handling is not the art of concealing every single error from the user and pretending like no error occurred.&lt;/blockquote&gt;

-- Well said. A well defined exception handling mechanism is a must for any software application.</description>
		<content:encoded><![CDATA[<blockquote><p>Exception handling is not the art of concealing every single error from the user and pretending like no error occurred.</p></blockquote>
<p>&#8211; Well said. A well defined exception handling mechanism is a must for any software application.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ob</title>
		<link>http://www.diovo.com/2008/11/dont-catch-exceptions-if-you-are-not-going-to-handle-them/comment-page-1/#comment-1129</link>
		<dc:creator>ob</dc:creator>
		<pubDate>Sun, 16 Nov 2008 14:46:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=330#comment-1129</guid>
		<description>Yep.  Checked Exceptions are a joke, invented in a short sighted world where there wouldnt be huge layered apps.

In your app API ALWAYS wrap checked exceptions as RuntimeExceptions, and make sure that the &quot;top level exception&quot; handler logs and can return the original exception in its, getCause() method.

Swallowing exceptions is definitely a chicken shit response to not knowing how to throw them up higher, and deal with them at the user level.</description>
		<content:encoded><![CDATA[<p>Yep.  Checked Exceptions are a joke, invented in a short sighted world where there wouldnt be huge layered apps.</p>
<p>In your app API ALWAYS wrap checked exceptions as RuntimeExceptions, and make sure that the &#8220;top level exception&#8221; handler logs and can return the original exception in its, getCause() method.</p>
<p>Swallowing exceptions is definitely a chicken shit response to not knowing how to throw them up higher, and deal with them at the user level.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aj</title>
		<link>http://www.diovo.com/2008/11/dont-catch-exceptions-if-you-are-not-going-to-handle-them/comment-page-1/#comment-1128</link>
		<dc:creator>aj</dc:creator>
		<pubDate>Sun, 16 Nov 2008 06:03:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=330#comment-1128</guid>
		<description>my team lead always catches and ignores exceptions ... no matter what ... he does it like

Try 
{
...
...
}
Catch (Exception ex) 
{
//empty
}

the reason he gives is, that it shows exception when he&#039;s debugging what ignores in runtime. this is lamest of all excuses to ignore exceptions i have ever heard.</description>
		<content:encoded><![CDATA[<p>my team lead always catches and ignores exceptions &#8230; no matter what &#8230; he does it like</p>
<p>Try<br />
{<br />
&#8230;<br />
&#8230;<br />
}<br />
Catch (Exception ex)<br />
{<br />
//empty<br />
}</p>
<p>the reason he gives is, that it shows exception when he&#8217;s debugging what ignores in runtime. this is lamest of all excuses to ignore exceptions i have ever heard.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SJS</title>
		<link>http://www.diovo.com/2008/11/dont-catch-exceptions-if-you-are-not-going-to-handle-them/comment-page-1/#comment-1126</link>
		<dc:creator>SJS</dc:creator>
		<pubDate>Sat, 15 Nov 2008 19:07:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=330#comment-1126</guid>
		<description>The problem isn&#039;t with exceptions, it&#039;s with &quot;this can&#039;t happen so who cares&quot; type thinking. It shows up in if-else-if constructs and switches as well.

switch ( foo ) {
   case BAR: handleBar(); break;
   case BAZ: handleBaz(); break;
   ...
   default: /* can&#039;t happen */
}

There are times when one doesn&#039;t *care* if some code throws an exception, but this is normally a tiny, tiny fraction of the time. The advice to print the stack trace to a log file (or even stderr) is an excellent policy.

The rest of the time, we presumably care, but either don&#039;t know what to do about an exception, or our API doesn&#039;t allow for checked exceptions.  Wrapping that checked exception is better than ignoring it:

try {
   someObject.mightThrowCheckedException();
} catch (SomeCheckedException scx) {
   throw new RuntimeException( scx);
}

And if it truly is a &quot;Can&#039;t Happen&quot;, why, an error is called for:

try {
   someObject.saysItThrowsCheckedExceptionButItLies();
} catch (LyingCheckedException lcx) {
   InternalError ie = new InternalError(
      &quot;Programmer Assumption Violation&quot; );
   ie.initCause( lcx );
   throw ie;
}

Or better yet:

public class PAVError extends InternalError {
   public PAVError( Throwable t ) {
      super(&quot;Programmer Assumption Violation&quot;);
      initCause( t );
  }
  ...
}

It would be nice if the difference between a checked and an unchecked exception were in how the exception is thrown, rather than the ancestor of the exception.</description>
		<content:encoded><![CDATA[<p>The problem isn&#8217;t with exceptions, it&#8217;s with &#8220;this can&#8217;t happen so who cares&#8221; type thinking. It shows up in if-else-if constructs and switches as well.</p>
<p>switch ( foo ) {<br />
   case BAR: handleBar(); break;<br />
   case BAZ: handleBaz(); break;<br />
   &#8230;<br />
   default: /* can&#8217;t happen */<br />
}</p>
<p>There are times when one doesn&#8217;t *care* if some code throws an exception, but this is normally a tiny, tiny fraction of the time. The advice to print the stack trace to a log file (or even stderr) is an excellent policy.</p>
<p>The rest of the time, we presumably care, but either don&#8217;t know what to do about an exception, or our API doesn&#8217;t allow for checked exceptions.  Wrapping that checked exception is better than ignoring it:</p>
<p>try {<br />
   someObject.mightThrowCheckedException();<br />
} catch (SomeCheckedException scx) {<br />
   throw new RuntimeException( scx);<br />
}</p>
<p>And if it truly is a &#8220;Can&#8217;t Happen&#8221;, why, an error is called for:</p>
<p>try {<br />
   someObject.saysItThrowsCheckedExceptionButItLies();<br />
} catch (LyingCheckedException lcx) {<br />
   InternalError ie = new InternalError(<br />
      &#8220;Programmer Assumption Violation&#8221; );<br />
   ie.initCause( lcx );<br />
   throw ie;<br />
}</p>
<p>Or better yet:</p>
<p>public class PAVError extends InternalError {<br />
   public PAVError( Throwable t ) {<br />
      super(&#8220;Programmer Assumption Violation&#8221;);<br />
      initCause( t );<br />
  }<br />
  &#8230;<br />
}</p>
<p>It would be nice if the difference between a checked and an unchecked exception were in how the exception is thrown, rather than the ancestor of the exception.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marko Simovic</title>
		<link>http://www.diovo.com/2008/11/dont-catch-exceptions-if-you-are-not-going-to-handle-them/comment-page-1/#comment-1125</link>
		<dc:creator>Marko Simovic</dc:creator>
		<pubDate>Sat, 15 Nov 2008 15:01:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=330#comment-1125</guid>
		<description>There seems to be a culture, where error handling is thought to be extraneous, that drives this sort of practice. What most developers need to understand is that error handling is ALWAYS going to be part of any program, and a large part at that (40-50% i&#039;d say).

Generally I&#039;m a bit mixed about checked exceptions but i still believe it goes back to the culture issue. Java enforces the handling, but it&#039;s still up to the developer to do something meaningful with those catch blocks.</description>
		<content:encoded><![CDATA[<p>There seems to be a culture, where error handling is thought to be extraneous, that drives this sort of practice. What most developers need to understand is that error handling is ALWAYS going to be part of any program, and a large part at that (40-50% i&#8217;d say).</p>
<p>Generally I&#8217;m a bit mixed about checked exceptions but i still believe it goes back to the culture issue. Java enforces the handling, but it&#8217;s still up to the developer to do something meaningful with those catch blocks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Botero-Lowry</title>
		<link>http://www.diovo.com/2008/11/dont-catch-exceptions-if-you-are-not-going-to-handle-them/comment-page-1/#comment-1123</link>
		<dc:creator>Alexander Botero-Lowry</dc:creator>
		<pubDate>Sat, 15 Nov 2008 08:17:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.diovo.com/?p=330#comment-1123</guid>
		<description>This is why checked exceptions are such a bad idea. Instead of having exceptions propagate and get noticed, Java emphasizes hiding them to ease development. Exceptions breaking your app is better then exceptions going unhandled because you just need to get the code out.</description>
		<content:encoded><![CDATA[<p>This is why checked exceptions are such a bad idea. Instead of having exceptions propagate and get noticed, Java emphasizes hiding them to ease development. Exceptions breaking your app is better then exceptions going unhandled because you just need to get the code out.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
