return true;
}
- $result = Horde_Util::assertDriverConfig($this->_params, array('phptype'), 'cache SQL', array('driver' => 'cache'));
- if (is_a($result, 'PEAR_Error')) {
- throw new Horde_Exception($result->getMessage());
- }
+ Horde_Util::assertDriverConfig($this->_params, array('phptype'), 'cache SQL');
$this->_write_db = DB::connect(
$this->_params,
return true;
}
- $result = Horde_Util::assertDriverConfig($this->_params, array('phptype'),
- 'Lock SQL', array('driver' => 'lock'));
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Horde_Lock_Exception($result->getMessage());
+ try {
+ Horde_Util::assertDriverConfig($this->_params, array('phptype'), 'Lock SQL');
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
+ throw new Horde_Lock_Exception($e);
}
- require_once 'DB.php';
$this->_write_db = &DB::connect(
$this->_params,
array('persistent' => !empty($this->_params['persistent']),
class Horde_Util
{
/* Error code for a missing driver configuration. */
- const HORDE_ERROR_DRIVER_CONFIG_MISSING = 1;
+ const DRIVER_CONFIG_MISSING = 1;
/* Error code for an incomplete driver configuration. */
- const HORDE_ERROR_DRIVER_CONFIG = 2;
+ const DRIVER_CONFIG = 2;
/**
* A list of random patterns to use for overwriting purposes.
/**
* Checks if all necessary parameters for a driver's configuration are set
- * and returns a PEAR_Error if something is missing.
+ * and throws an exception if something is missing.
*
* @param array $params The configuration array with all parameters.
* @param array $fields An array with mandatory parameter names for this
* driver.
* @param string $name The clear text name of the driver. If not
* specified, the application name will be used.
- * @param array $info A hash containing detailed information about the
- * driver. Will be passed as the userInfo to the
- * PEAR_Error.
+ *
+ * @throws Horde_Exception
*/
- static public function assertDriverConfig($params, $fields, $name,
- $info = array())
+ static public function assertDriverConfig($params, $fields, $name)
{
$info = array_merge($info, array(
'params' => $params,
));
if (!is_array($params) || !count($params)) {
- return PEAR::throwError(sprintf(_("No configuration information specified for %s."), $name), self::HORDE_ERROR_DRIVER_CONFIG_MISSING, $info);
+ throw new Horde_Exception(sprintf('No configuration information specified for %s.', $name), self::DRIVER_CONFIG_MISSING);
}
foreach ($fields as $field) {
if (!isset($params[$field])) {
- return PEAR::throwError(sprintf(_("Required \"%s\" not specified in configuration."), $field, $name), self::HORDE_ERROR_DRIVER_CONFIG, $info);
+ throw new Horde_Exception(sprintf('Required "%s" not specified in configuration.', $field, $name), self::DRIVER_CONFIG);
}
}
}