Yep. Its very evil. ;-)

The only time I use it in serious code is when Im actually expecting an
exception to be thrown under certain circumstances but I quite specifically
dont intend to do anything about it.
In these cases its still bad practice to use catch(Exception x) though.

One should specifically catch the exception type that one expects and plans
to ignore - and furthermore one should put in comments explaining ones
reasons to whomever is maintaining the code years later...

-----Original Message-----
From: Dennis Doubleday [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 18, 2002 22:53
To: 'Struts Users Mailing List'; [EMAIL PROTECTED]
Subject: RE: [Struts Tip] #15 Use chained exceptions. Design
consideration.




> -----Original Message-----
> From: Andrew Hill [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 18, 2002 7:31 AM
> To: Struts Users Mailing List
> Subject: RE: [Struts Tip] #15 Use chained exceptions. Design
> consideration.
>
>
> eeee. thats horrible.
> I use:
>
> catch(Exception e)
> {
>   ;
> }
>
> to make it absolutely clear (ie: that I didnt just get
> distracted and forget to write the code for that block)

I can't think of many (any?) times when that is good practice. It makes
it very hard to debug cases where some totally unexpected Exception
subclass is thrown and silently swallowed. Sure, we've all done it
sometimes, but I wouldn't talk about it on a mailing list :-)

Case in point that recently happened to a co-worker: he had an empty
catch in a place where "nothing could possibly go wrong and even if it
did you couldn't do anything about it." However, later code refactoring
caused a ClassCastException to occur and be caught silently. It was very
confusing.


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to