SourcePro DB handles errors differently depending upon how they are generated. The following sections describe error messages used with the DB Access Module for PostgreSQL.
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 PQresultErrorMessage()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.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.