By default, PEAR modules will return errors from a function call. These errors take the form of PEAR_Error objects. The correct way to handle these is:

<?php
require_once 'PEAR/DB.php';
$db = DB::connect($dsn);
if (PEAR::isError($db)) {
    //This is an example of what you can do when an error happens. You could also log the error or try to recover from it.
    die($db->getMessage().' '.$db->getUserInfo());
}
?>

This should be done for all calls which are documented to return an error.

Another way to handle errors in PEAR is to use a global error handler. A simple example is below. This will die on all PEAR_Errors and show the reason for the error:

<?php
function handle_pear_error($e) {
    die($e->getMessage().' '.print_r($e->getUserInfo(), true));
}
require_once 'PEAR.php';
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_pear_error');
?>