Errors and RWDBStatus
When an error or warning is generated by an Access Module call to the PostgreSQL libpq API, information about the event is retrieved via a call to
PQerrorMessage() or P
QresultErrorMessage()and
PQresStatus(),and 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 the PostgreSQL libpq API:
errorCode:
RWDBStatus::serverError if an error or a warning occurred.
message: "
command failed" if an error or a warning occurred.
vendorMessage1: the error message returned by the call to
PQerrorMessage() or
PQresultErrorMessage() vendorMessage2: the result status returned by
PQresStatus() vendorError1: the result status returned by
PQresultStatus() An application can use the mapping shown previously to write an error handler that reports errors on cerr.
For example:
void myErrorHandler(const RWDBStatus & stat)
{
if (!stat.isValid()) {
cerr << stat.vendorMessage1() << endl;
cerr << stat.vendorMessage2() << endl;
}
All errors associated with the status will be reported.