January 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9255

           Summary: Inconsistent .file field of thrown exceptions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-01 13:14:23 PST ---
module foo.bar;

import core.exception;
import std.stdio;

void main()
{
    try
    {
        assert(0);
    }
    catch (Throwable e)
    {
        writeln(e.file);
    }

    try
    {
        throw new Exception("");
    }
    catch (Throwable e)
    {
        writeln(e.file);
    }
}

$ rdmd test.d

foo.bar
test.d

The assert sets the 'file' field to the module name, whereas an Exception sets it to the file name. This makes it hard to parse the file field in order to produce error messages which can further be parsed by e.g. editors or IDE tools (for example double-click on a unittest failure message could automatically open a file, *if* the path is actually valid).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9255



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-01 13:25:44 PST ---
In my codebase even assert() itself is inconsistent with itself, I don't know why. Sometimes it uses the module name, other times the file name. I guess the best thing to do is use a wrapper which throws AssertError on its own until this issue is fixed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9255


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
         AssignedTo|nobody@puremagic.com        |andrej.mitrovich@gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-01 15:20:19 PST ---
https://github.com/D-Programming-Language/dmd/pull/1426

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home