Friday, August 10, 2012

Error messages vs format strings

Sometimes we see sloppy handling of error messages where format strings are popping up. Of course those form strings should not be displayed as is, bit should be used to compose a complete error message. Here is an example with GAMS/Cplex:

*** CPLEX Error  5002: Q in %s is not positive semi-definite.

Another example is coming from the Delphi run time, when a file could not be written. This is from an exception generated in this case:

EInOutError: Invalid file name - %s