Line number of Exception instantiation

bearophile bearophileHUGS at lycos.com
Thu Mar 4 10:58:54 PST 2010


What do you think of the idea of the Exception to remember (so later it can be shown if uncaught) the line number and file name where it was instantiated?

void foo() {
    auto e = new Exception(""); // instantiation line number here
    throw e;
}
void main() {
    foo();
}

Exceptions get caught, rethrown, stored, etc. But in many cases in my code they are instantiated close to where the cause was. So knowing such line number can be useful (if you are using a debugger this is not so useful).

Bye,
bearophile



More information about the Digitalmars-d mailing list