DB Access Module for MySQL User’s Guide : Chapter 2 Technical Information : Error Messages
Error Messages
SourcePro DB handles errors differently depending upon how they are generated. The following sections describe error messages used with the DB Access Module for MySQL.
Errors
Because the DB Interface Module does not simulate behavior that is not provided in the MySQL C API and MySQL SQL grammar, certain functions of the DB Interface Module are reported as errors using the error code RWDBStatus::notSupported.
There is a much broader range of possible errors that depend entirely on the underlying MySQL library in use. Errors of this sort are most likely to occur during the execution of advanced SQL via a call to mysql_real_query(). These errors are reported using the error code RWDBStatus::serverError.
We make no attempt to mitigate against such errors, but when an error does occur, information is transferred to DB Interface Module objects as described below.
Errors and RWDBStatus
When an error or warning is generated by an Access Module call to the MySQL API, information about the event is retrieved via a call to mysql_error() and mysql_errno() and is then transferred to an RWDBStatus. This RWDBStatus object is passed as a parameter to the installed error handler. The following list provides the format that RWDBStatus uses to describe events reported by MySQL:
errorCode: RWDBStatus::serverError if an error occurred, or RWDBStatus::ok if a warning is being generated
message: "SQL Execution call failed" if an error occurred, or "Success with info" if a warning is being generated
vendorMessage1: the error message output from the mysql_error() call; for example, "Invalid Table"
vendorMessage2: [not used]
vendorError1: the native error code parameter output from the mysql_error() call
vendorError2: [not used]
An application can use the mapping shown previously to write an error handler that reports errors on cerr and issues warnings on clog. For example:
 
void myErrorHandler(const RWDBStatus& stat)
{
if (stat.errorCode() != RWDBStatus::ok) // Errors
cerr << stat.vendorMessage1();
else // Warnings
clog << stat.vendorMessage1();
}
All errors associated with the status will be reported.