Re: Is there a better way to throw this exception?

2013-06-10 Thread David Holmes
Sorry missed the return after once() in the original code. David On 7/06/2013 5:53 PM, David Holmes wrote: Peter, On 7/06/2013 12:57 AM, Peter Levart wrote: On 06/06/2013 11:42 AM, Weijun Wang wrote: Hi All I have a method that could throw two kinds of checked exceptions and possibly other

Re: Is there a better way to throw this exception?

2013-06-07 Thread John Rose
Puzzles! Probably you can use the new syntax "catch (Ex1|Ex2 ex)" to bind the first exception to a union type. You'll have to split the loop, but you could use a common iterator. for (Iterator it = all changes; it.hasNext(); ) { try { it.next(); once(); return; } catch (One|Two ex) {

Re: Is there a better way to throw this exception?

2013-06-07 Thread David Holmes
Peter, On 7/06/2013 12:57 AM, Peter Levart wrote: On 06/06/2013 11:42 AM, Weijun Wang wrote: Hi All I have a method that could throw two kinds of checked exceptions and possibly other unchecked ones: void once() throws One, Two Now I have a wrapper method that calls once() for multiple ti

Re: Is there a better way to throw this exception?

2013-06-06 Thread Steven Schlansker
On Jun 6, 2013, at 2:42 AM, Weijun Wang wrote: > Hi All > > I have a method that could throw two kinds of checked exceptions and possibly > other unchecked ones: > > void once() throws One, Two > > Now I have a wrapper method that calls once() for multiple times, and want to > throw the f

Re: Is there a better way to throw this exception?

2013-06-06 Thread Steven Schlansker
On Jun 6, 2013, at 2:42 AM, Weijun Wang wrote: > Hi All > > I have a method that could throw two kinds of checked exceptions and possibly > other unchecked ones: > > void once() throws One, Two > > Now I have a wrapper method that calls once() for multiple times, and want to > throw the f

Re: Is there a better way to throw this exception?

2013-06-06 Thread Peter Levart
On 06/06/2013 11:42 AM, Weijun Wang wrote: Hi All I have a method that could throw two kinds of checked exceptions and possibly other unchecked ones: void once() throws One, Two Now I have a wrapper method that calls once() for multiple times, and want to throw the first exception if *al

Is there a better way to throw this exception?

2013-06-06 Thread Weijun Wang
Hi All I have a method that could throw two kinds of checked exceptions and possibly other unchecked ones: void once() throws One, Two Now I have a wrapper method that calls once() for multiple times, and want to throw the first exception if *all* fails. Now it looks like void multip