Line number of Exception instantiation

Robert Jacques sandford at jhu.edu
Thu Mar 4 16:32:14 PST 2010


On Thu, 04 Mar 2010 13:58:54 -0500, bearophile <bearophileHUGS at lycos.com>  
wrote:

> 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

You mean, like enforce(false, "message")?



More information about the Digitalmars-d mailing list