In case of failure, most of the DB functions return a DB_Error object which contains information about the error. DB_Error offers the same functions as PEAR_Error.
The text messages returned by DB_Error::getMessage() are consistent between each DBMS.
The error code integers returned by DB_Error::getCode() are also consistent between each DBMS. The integers returned are based on the DB_ERROR_* constants defined in DB.php.
DB_Error::getDebugInfo() and DB_Error::getUserInfo() return complete native DBMS error reports.
Example 26-1. Trapping errors and determining what happened
|