-
Notifications
You must be signed in to change notification settings - Fork 49
Proper error log and report within VAPOR
sgpearse edited this page Mar 29, 2021
·
4 revisions
Currently VAPOR provides an error log and error report mechanism. These mechanisms, instead of custom or QT error handling mechanisms, should be used in VAPOR.
VAPOR provides a function, static void MyBase::SetErrMsg(const char *format, ...)
, to log an error message.
-
SetErrMsg()
supports formatted strings, just likefprintf()
in C. -
SetErrMsg()
lives in the "vapor core" side, but not "vapor GUI" side. As a result, any error messages that generated from "vapor core" should be logged bySetErrMsg()
. -
SetErrMsg()
only logs the error, but does not report to the user.
Unless otherwise documented any function or method that returns an integer or pointer should log a message with SetErrMsg() on failure, indicated by a negative int or NULL pointer, respectively.
Functions or methods that return a boolean status should not, unless otherwise documented, log an error message on failure (returning false).
VAPOR provides a set of macros for error reporting.
These macros differ from SetErrMsg()
in that:
- These macros live in the "vapor GUI" side, but not in the "vapor core" side. Thus, an error occurred in the "vapor core" cannot be reported through these macros.
- These macros will pop up a window box to report the error message, along with all errors reported on the "vapor core" side, via MyBase::SetErrorMsg().
- The error message in the pop up window is the latest message recorded by
SetErrMsg()
, followed by an optional message passed intoMSG_ERR(M)
. (Stas, is this correct? ) - The message passed into
MSG_ERR(M)
does not support formatted strings. - The three macros have different characteristics. More specifically, blahblah (Stas, could you fill in here? )
- If a method/function returns a status value it should in general not report a message with MSG_ERR(), but instead rely on the calling function to report any errors. I.e. a function returning a status value should in general use SetErrMsg() to log the message.