[Issue 9625] New: assertNotThrown should print exception msg if no msg is provided

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 1 12:33:18 PST 2013


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 at gmail.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-03-01 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: -------


More information about the Digitalmars-d-bugs mailing list