Skip to content

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.

Error logging

VAPOR provides a function, static void MyBase::SetErrMsg(const char *format, ...), to log an error message.

  • SetErrMsg() supports formatted strings, just like fprintf() 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 by SetErrMsg().
  • SetErrMsg() only logs the error, but does not report to the user.

When to log error messages

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

Error reporting

VAPOR provides a set of macros for error reporting.

  1. MSG_ERR(M)
  2. MSG_WARN(M)
  3. MSG_DIAG(M)

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 into MSG_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.