IWETHEY v. 0.3.0 | TODO
1,095 registered users | 1 active user | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New In development yes
Actually if you are doing server side development the container will ctach the exception for you and not terminate. The point is that you want ot handle these differently because they represent programming errors and you don't want to miss them.
New Re: In development yes
The point is that you want ot handle these differently because they represent programming errors and you don't want to miss them.

There are a lot of programming errors that I don't want to miss, but not all of them (by any stretch of the imagination) are represented by RuntimeExceptions. If I misspell the table name in an SQL statement, that's a programmer error too, but an SQLException is not a Runtime Exception.

It seems very artificial to say Checked Exceptions should be caught and Uncheck exceptions should not be caught. If I call function f() and it fails, I don't really care if it failed because a null pointer was dereferenced or a file couldn't be openned.

Furthermore, there is a significant number of programmers who consider checked exceptions a language wart and are moving to unchecked exceptions (witness Scott's response in this thread).
--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Agreed
which is why you should not just catch Exception, you end up swallowing more then you can chew.

I agree that checked exceptions are a bad idea. They end up polluting the code with a lot if extraneous code. Unfortuntely, Java forces you to handle checked exceptions.
New So wouldn't the remedy be...
BLuke cautions and laments:
which is why you should not just catch Exception, you end up swallowing more then you can chew.

I agree that checked exceptions are a bad idea. They end up polluting the code with a lot if extraneous code.
Solution: Use only unchecked ones; i.e, make all your own ones descend from RuntimeException (or whatever the name was).


Unfortuntely, Java forces you to handle checked exceptions.
Hmm... So how about, in stead of wrapping and re-throwing every exception "ten times" (cf your comment in another sub-thread), you'd catch all checked exceptions that you have to handle, on the lowest level where they occur, and wrap and re-throw them -- once and once only, wrapped in one of your own RuntimeException-descended ones?

That's the best way I can see of handling a bad situation you can't really change; at least then you won't have to screw around with your intervening layers on each change at a higher or lower level.

Right?


   [link|mailto:MyUserId@MyISP.CountryCode|Christian R. Conrad]
(I live in Finland, and my e-mail in-box is at the Saunalahti company.)
You know you're doing good work when you get flamed by an idiot. -- [link|http://www.theregister.co.uk/content/35/34218.html|Andrew Wittbrodt]
New cf. Spring Framework :-)
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New I agree ...
the problem is convincing everyone else. Most people still believe in the checked exception mantra. What makes it worse is that the Java libraries use checked exceptions all over the place.
     Exception Handling Policy - (JimWeirich) - (48)
         Possibly it depends on what level of code you are writing... - (Simon_Jester) - (38)
             Ditto. - (admin) - (37)
                 Because checked exceptions are STOOPID! - (tuberculosis) - (35)
                     One reason I like Spring Framework - (admin) - (1)
                         Absolutely - (bluke)
                     Re: Because checked exceptions are STOOPID! - (dshellman) - (23)
                         One respectable reason - (admin) - (13)
                             Re: One respectable reason - (dshellman) - (12)
                                 The problem with Java model is that I cannot - (Arkadiy) - (1)
                                     Re: The problem with Java model is that I cannot - (dshellman)
                                 But that would (i.e, *does*) defeat the whole purpose! - (CRConrad) - (3)
                                     ICLRPD (new thread) - (drewk)
                                     Re: But that would (i.e, *does*) defeat the whole purpose! - (dshellman) - (1)
                                         Sorry, either I don't get your meaning, or you didn't mine. - (CRConrad)
                                 What ends up happening ... - (bluke) - (5)
                                     Re: What ends up happening ... - (dshellman) - (4)
                                         Re: What ends up happening ... - (tuberculosis)
                                         You didn't answer the question ... - (bluke) - (2)
                                             Re: You didn't answer the question ... - (dshellman) - (1)
                                                 A number of comments - (bluke)
                         We already discussed this - (ben_tilly) - (8)
                             Re: We already discussed this - (dshellman) - (7)
                                 Blame the tool - (tuberculosis)
                                 You're right, that is unfortunate - (ben_tilly) - (5)
                                     Re: You're right, that is unfortunate - (dshellman) - (4)
                                         You have to balance benefit/cost - (ben_tilly) - (3)
                                             s/Knuth/Dijkstra/ - (a6l6e6x) - (2)
                                                 I had it right the first time - (ben_tilly) - (1)
                                                     I stand corrected then. - (a6l6e6x)
                     Re: Because checked exceptions are STOOPID! - (dshellman) - (8)
                         Hmm... - (CRConrad)
                         One phrase says it all. - (Arkadiy) - (6)
                             Caught my eye too - (tuberculosis)
                             Re: One phrase says it all. - (dshellman) - (4)
                                 I remain unconvinced - (tuberculosis)
                                 A Further Question on the Code Example - (JimWeirich) - (1)
                                     Re: A Further Question on the Code Example - (dshellman)
                                 Bad for class libraries? - (Arkadiy)
                 Re: Ditto. - (JimWeirich)
         I meant Exception the class - (bluke) - (7)
             Don't catch null pointer exceptions? - (JimWeirich) - (6)
                 In development yes - (bluke) - (5)
                     Re: In development yes - (JimWeirich) - (4)
                         Agreed - (bluke) - (3)
                             So wouldn't the remedy be... - (CRConrad) - (2)
                                 cf. Spring Framework :-) -NT - (admin)
                                 I agree ... - (bluke)
         Another reason to catch specifics - (jb4)

There should be an opportunity for somebody here.
150 ms