[Issue 7675] std.format needs better exception messages

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 26 09:52:49 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7675



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-05-26 09:54:34 PDT ---
If anyone else is annoyed by this you can use a workaround like this:

/** Workaround for Issue 7675 - std.format needs better exception messages */
string safeFmt(string file = __FILE__, int line = __LINE__, T...)(string fmt, T
args)
{
    auto specCount = count(fmt, "%s");
    enforce(specCount == T.length, 
            new Exception(format("Arg count %s doesn't match spec count %s.",
T.length, specCount), file, line));
    return format(fmt, args);
}

That implies using %s exclusively and it only throws on argument count
mismatch, but it's still a shitload better than "Error occurred somewhere, have
fun debugging!".

Throwing exceptions in Phobos with no information on what went wrong should be
*banned*.

-- 
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