The Right Approach to Exceptions
yebblies at nospamgmail.com
Sat Feb 18 21:59:49 PST 2012
"Nick Sabalausky" <a at a.a> wrote in message
news:jhprac$2aj$1 at digitalmars.com...
> The only problem I've ever had with them is that there's no templated
> catch blocks, so you can't handle two different exceptions with the same
> code without violating DRY or worse: catching the common base type and
> rethrowing when it's not what you wanted. Toss in templated catch blocks,
> and I've have no problem at all.
Do you mean something like this?
catch (e : ThisException, ThatException, OtherException)
static assert(is(typeof(e) == CommonType!(ThisException, ThatException,
catch (Exception e)
// Every other type derived from Exception
Or do you think the full power to be able to template catch blocks as if
they were functions would be useful for something?
More information about the Digitalmars-d