Changeset 403

Show
Ignore:
Timestamp:
10/14/07 23:02:31 (1 year ago)
Author:
andrei
Message:

Improved error messages when writef* are called without a format string

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • candidate/phobos/std/stdio.d

    r399 r403  
    337337{ 
    338338    FileWriter!(char) w; 
     339    static const errorMessage = 
     340        "You must pass a formatting string as the first" 
     341        " argument to writef. If no formatting is needed," 
     342        " you may want to use write."; 
    339343    static if (!is(typeof(args[0]) : FILE*)) 
    340344    { 
     345        static assert(isSomeString!(T[0]), errorMessage); 
    341346        w.backend = stdout; 
    342347        FLOCK(w.backend); 
     
    346351    else 
    347352    { 
     353        static assert(isSomeString!(T[1]), errorMessage); 
    348354        w.backend = args[0]; 
    349355        FLOCK(w.backend); 
     
    380386    // Duplicate code so we don't duplicate the stack; replace with macro l8r 
    381387    FileWriter!(char) w; 
     388    static const errorMessage = 
     389        "You must pass a formatting string as the first" 
     390        " argument to writefln. If no formatting is needed," 
     391        " you may want to use writeln."; 
    382392    static if (!is(typeof(args[0]) : FILE*)) 
    383393    { 
     394        static assert(isSomeString!(T[0]), errorMessage); 
    384395        w.backend = stdout; 
    385396        FLOCK(w.backend); 
     
    389400    else 
    390401    { 
     402        static assert(isSomeString!(T[1]), errorMessage); 
    391403        w.backend = args[0]; 
    392404        FLOCK(w.backend);