Chaining exceptions

Chris Nicholson-Sauls ibisbasenji at gmail.com
Fri Nov 20 21:44:24 PST 2009


BCS wrote:
> Hello Jesse,
> 
>> On Wed, 18 Nov 2009 18:27:47 -0800, Andrei Alexandrescu wrote:
>>
>>> Thanks! Question - is there a way to fetch the current Throwable from
>>> within a finally clause?
>>>
>>> Andrei
>>>
>> I'm pretty sure you can't since finally isn't passed an exception. I
>> also don't see anything in my quick search.
>>
> 
> That stands to reason because in some cases (when things go correctly) 
> there isn't one.
> 
> 

One hopes.  Just the same: (hypothetical syntax incoming)

try {
	// ...
}
catch ( ExceptionA exa ) {
	// ...
}
catch ( ExceptionB exb ) {
	// ...
}
finally ( x ) {
	// ...
	if ( x ) throw new ExceptionC( x );
}

And obviously if finally has no () it doesn't bother with the feature.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list