www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9625] New: assertNotThrown should print exception msg if no msg is provided

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

           Summary: assertNotThrown should print exception msg if no msg
                    is provided
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: andrej.mitrovich gmail.com
        ReportedBy: andrej.mitrovich gmail.com



12:33:17 PST ---
Note the implementation:

void assertNotThrown(T : Throwable = Exception, E)
                    (lazy E expression,
                     string msg = null,
                     string file = __FILE__,
                     size_t line = __LINE__)
{
    try
        expression();
    catch(T t)
    {
        immutable tail = msg.empty ? "." : ": " ~ msg;

        throw new AssertError(format("assertNotThrown failed: %s was thrown%s",
                                     T.stringof,
                                     tail),
                              file,
                              line,
                              t);
    }
}

Specifically this line:
    immutable tail = msg.empty ? "." : ": " ~ msg;

This should rather be:
    immutable tail = ": " msg.empty ? t.msg : msg;

That way you get back the exception message if you haven't provided your own.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9625




12:45:38 PST ---

 This should rather be:
     immutable tail = ": " msg.empty ? t.msg : msg;
That exact line wouldn't be correct but I'll implement this properly in a pull now. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9625


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



12:52:20 PST ---
https://github.com/D-Programming-Language/phobos/pull/1185

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9625


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



11:02:46 PST ---
Hmm github bot hasn't posted here. It's fixed though:
https://github.com/D-Programming-Language/phobos/commit/ba4095de5f2c6c62dbec45b71ec3e4ba3d802f90

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 02 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9625




13:40:38 PST ---

 Hmm github bot hasn't posted here. It's fixed though:
 https://github.com/D-Programming-Language/phobos/commit/ba4095de5f2c6c62dbec45b71ec3e4ba3d802f90
It was due to a bad commit message, here's gitbot:
 https://github.com/D-Programming-Language/phobos/commit/e2831a5f2a7f3a8b0df4e475ff4f79fea2ff5c0f
 Fixes Issue 9265 - assertNotThrown should emit msg from thrown exception if
 available.
 
 https://github.com/D-Programming-Language/phobos/commit/ba4095de5f2c6c62dbec45b71ec3e4ba3d802f90

 
 Issue 9265 - assertNotThrown should emit msg from thrown exception if
 available.
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 02 2013