Saturday, December 1, 2012

Standard Error Output

Command line error messages should be sent to the standard error channel; the Qt qWarning() function should not be used because these messages can be disabled.  The cout() function was modified to accept a FILE stream (channel) pointer, either stdout or stderr, with stdout the default.  The qWarning() calls were changed to cout(stderr), which made these lines cleaner because the qPrintable() function is not longer needed to output QString values.

There was also a qWarning() call in the Tester run function when table errors are detected.  These only occur when there are problems in the table entries and are followed by a qFatal() call (which terminates the program).  This qWarning() call was changed to a qCritical() call, whose messages can not be disabled.

Previously, to get the usage message, invalid arguments had to be specified.  To get the usage message without returning an error, new help options were added (either '-?' or '-h').  The usage message will be output to standard output channel when using these options, but to the standard error channel for invalid arguments.

When an error occurs in the Tester run function, like when the test file can't be opened, the standard output channel needs to be closed and the standard error channel opened to output the error message.  The new function coutClose() was added to the CommandLine class, which closes the current channel (if open), which is called before outputting the error message from the Tester instance.  The code for this function was pulled from the destructor, which was replaced with a call to the new function.

[commit e64eadee4a]

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)