Yep. That's my approach. > Guys If you don't know how to handle exception for a given method then > you are better off simply throwing it.
This sentence may confuse some who will assume they have to catch it in the first place. Maybe a better phrase is: "If you don't know how to handle exception for a given method then just don't catch it." Hey, I just had an idea. Why not compile this with Reinier's checkless compiler, jar it up and include it in your normal projects.. public class Throw { public static void unchecked(Throwable throwable) { throw throwable; } } all you need to do, where you would normally wrap the exception in a runtime exception is do this.. public void method() { try { ... } catch (SQLException sqle) { Throw.unchecked(sqle); } } On Aug 21, 6:30 pm, "a.efremov" <a.efre...@javasmith.org> wrote: > Hello, > > Let me to say what I think on that topic. > Guys If you don't know how to handle exception for a given method then > you are better off simply throwing it. Just add it to the method > declaration. That's all about that. > Handle only exceptions in case you are know for sure how to deal with > a failure/error. > > In some cases you can simply wrap an exception into RuntimeException. > It sounds like you convert it to an error intentionally. kinda > exception handling. It makes sense for wealth of situations. > > Don't write useless boilerplate code that in many cases is cause of an > error. Keep the things as simple as there are. > > alexander > > On Aug 18, 4:55 am, Christian Catchpole <christ...@catchpole.net> > wrote: > > > > > No, i just let that go up. I really try to avoid the declare as null > > then set thingy. > > > On Aug 18, 12:03 pm, Casper Bang <casper.b...@gmail.com> wrote: > > > > You neglect to handle the checked exception declared by > > > prepareStatement no? > > > > PreparedStatement stmt = null; > > > try{ > > > stmt = connection.prepareStatement(sql); > > > final ResultSet rs = stmt.executeQuery(); > > > try{ > > > while (rs.next()){ > > > // Stuff... > > > { > > > } > > > finally{ > > > rs.close(); > > > }} > > > > catch(SQLException e){ > > > // Logging...} > > > > finally{ > > > try{ > > > stmt.close(); > > > } > > > catch(SQLException whoTheFuckCares){ > > > }; > > > > } > > > > Really, how many other ways are there to do it I wonder now? (Apart > > > from wrapping certain things, like the last try-catch clause in some > > > general purpose "closer util"?). > > > > /Casper --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to javaposse@googlegroups.com To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---