Errors

From Open Babel

Jump to: navigation, search

Errors and warnings in Open Babel are handled internally by a flexible system motivated by a few factors:

The OBMessageHandler class includes documentation on the new error system, which is summarized below:

Multiple error/warning levels exist and should be used by code. Rough divisions include:

The default filter level is set to obWarning, which means that users are told of critical errors, but not non-standard formatting of input files.

A global error handler obErrorLog is defined and can be used as illustrated below:

    if (atomIndex < 1 || atomIndex > mol.NumAtoms() )
        obErrorLog.ThrowError(__FUNCTION__, "Requested Atom Out of Range", obDebug);
     stringstream errorMsg;
     errorMsg << " Could not parse line in type translation table types.txt -- incorect number of columns";
     errorMsg << " found " << vc.size() << " expected " << _ncols << ".";
     obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obInfo);

The __FUNCTION__ builtin is defined by many compilers (e.g., GCC) but can be defined to an empty string on some platforms without this compiler extension. It is currently used to provide information about which function is yielding the error or debugging information. This extension should eventually be replaced in the Open Babel code by __func__ which is now part of the C99 standard.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox