On Friday, 8 March 2013 at 06:05:02 UTC, Maxim Fomin wrote:
Actually no.
class myException1 : Exception { this() { super("1"); } }
class myException2 : Exception { this() { super("2"); } }
[...]
Thanks! That solves 99% of my problem. I wasn't aware that I
could check the derived type from a base class reference like
that.
The only remaining 1% is that I have a bit more boiler plate code
for my catch, because I still have to always explicitly catch
something otherwise I cannot )for example) write a function to
get the exception and perform work on it and then rethrow.
Instead I have to
catch( Exception E )
{
throw dostuff( E );
}
in C++ I could do simply this
catch(...)
{
// do stuff could get the exception on its own
throw dostuff();
}
Seems trivial, but over hundreds of functions it becomes more of
a significant productivity issue.
I can live with it, but I still think D could use an ability to
rethrow whatever was the last exception with having to explicitly
catch it.
--rt