Oops... Where you see:
throw handleException(e) replace with: throw new RuntimeException(handleException(e)); Andre -----Mensagem original----- De: Andre Dantas Rocha [mailto:andre.dantas.ro...@uol.com.br] Enviada em: quarta-feira, 8 de abril de 2009 10:18 Para: 'Commons Developers List' Assunto: RES: Possible incubation? Hi Jorg, I understand your point, and maybe the framework need some improvement. Today it's only an initial code (any help and ideas are welcome). In my opinion handleException() must handle the original exception and all exceptions that occurs inside it, so the code ever stops in this method: // code in framework public Throwable handleException(Throwable t) { try { ... } catch (Exception e) { // appropriate handling here } finally { return t; } } // usage try { doSomethingRisky(); catch(Exception e){ handleException(e); } If you want to propagate the original exception, you can do this: try { doSomethingRisky(); catch(Exception e){ throw handleException(e); } Maybe we can add a new parameter in handleException() specifying if the inside exception must be propagated. What do you think? Any new idea is valuable to solve the problem, if you have one please share... And... thanks for showing this kind of problem. Regards, Andre -----Mensagem original----- De: sebb [mailto:seb...@gmail.com] Enviada em: quarta-feira, 8 de abril de 2009 09:49 Para: Commons Developers List Assunto: Re: Possible incubation? On 08/04/2009, Andre Dantas Rocha <andre.dantas.ro...@uol.com.br> wrote: > Jorg, > > I don't agree with this point at all: "having a method call in a catch block > > is > likely to cause problems for code analysis tools - as well as humans - > as one cannot immediately tell if the code continues or not" > > > I believe it is possible to know if the code continues or not, for example, > if you rethrow the exception at the end of handle() method. Reading your > message, however, I realized that it is a good idea to make handle() method > works more safely allowing it to throw original exception in case of error > inside it. So does the following code continue or not? try { doSomethingRisky(); catch(Exception e){ handleException(e); } And how can you be sure? > Andre > > -----Mensagem original----- > De: sebb [mailto:seb...@gmail.com] > Enviada em: quarta-feira, 8 de abril de 2009 07:21 > > Para: Commons Developers List > Assunto: Re: Possible incubation? > > > On 08/04/2009, Jörg Schaible <joerg.schai...@gmx.de> wrote: > > Hi Andre, > > > > Andre Dantas Rocha wrote at Dienstag, 7. April 2009 14:38: > > > > > > > Hi all, > > > > > > This message was originally sent to incubator list, but they suggest to > > > post it here because *maybe* the idea can fit in Commons project. > > > > > > I'm developing a framework called Jeha. The main idea is to provide > easy > > > exception description and handling using annotations in methods and > > > classes > > > and some commons handlers. I believe that the idea is simple, but > > > powerful. > > > > > > The initial code and start guide of framework are here: > > > > > > <http://sourceforge.net/project/showfiles.php?group_id=242203&package_id=294 > > > 931&release_id=650572> > > > > > > http://sourceforge.net/project/showfiles.php?group_id=242203&package_id=2949 > > > 31&release_id=650572 > > > > > > I'd like to hear from community if this idea is valuable for a possible > > > incubation. > > > > > > Please let me know your opinion. > > > > > > It might be only me, but I see this approach a bit critical. On one hand > > you're right, writing exception code is quite tedious sometimes, but with > > your solution you wipe out any useful method signature regarding > exception > > declaration. What happens if I don't wanna handle certain exception types > > or RuntimeException instances? I cannot simply rethrow from the handler. > > I wondered about that. Also, having a method call in a catch block is > likely to cause problems for code analysis tools - as well as humans - > as one cannot immediately tell if the code continues or not. > > Now, having a way to perform the same code for multiple exceptions > would sometimes be useful. Dunno whether that could be implemented. > > > - Jörg > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > > For additional commands, e-mail: dev-h...@commons.apache.org > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org