[concurrency-interest] Critique my class ?

Gregg Wonderly gregg at cytetech.com
Thu Sep 22 17:13:18 EDT 2005

Tim Peierls wrote:
> Chris Burnley wrote:
>      protected void force() throws InterruptedException, 
> SyncFailedException {
> and remove the InterruptedException catch clause.
>>         } catch (WaitFailureException e) {
>>             throw new SyncFailedException(e.toString());       
> If you don't have to flatten the failure into string, don't. How about:
>   throw new SyncFailedException(e.getCause());

The ugly pattern that I always use is to create the wrapper exception with the message from the thrown exception that I 
caught, and then call initCause() with the caught exception.

	throw (SyncFailedException)new SyncFailedException(e.toString()).initCause(e);

This gets a little long to type.  A standard annotation would be nice for this pattern.

Gregg Wonderly

More information about the Concurrency-interest mailing list