www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3883] New: Line number and file name of Exception instantiation

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3883

           Summary: Line number and file name of Exception instantiation
           Product: D
           Version: 2.040
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: druntime
        AssignedTo: sean invisibleduck.org
        ReportedBy: bearophile_hugs eml.cc



I suggest to add to Exception (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 they are
instantiated close to where their cause is. So knowing such line number can be
useful (if you are using a debugger this is not so useful).

The compiler fills such fields automatically, so the syntax usage of Exception
is unchanged. Such fields can be immutable, and eventually they can be read by
user code too.

The name and file name added increases the size of the Exception instances (and
the binary size too a little), but I think this can't cause problems in normal
programs.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 05 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3883


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 21 2012