replace Exception on GeneralException

This commit is contained in:
Vyacheslav Agafonov
2011-11-25 19:50:41 +04:00
parent d4705b1c89
commit 443655064c
11 changed files with 26 additions and 20 deletions

View File

@ -40,7 +40,7 @@ class Db
}
if (!is_array($config)) {
throw new Exception('Connection parameters must be an array');
throw new GeneralException('Connection parameters must be an array');
}
$driver = 'MySQLiDriver';
@ -52,7 +52,7 @@ class Db
$connection = new $driver($config);
if (!$connection instanceof DbDriver) {
throw new Exception('Database driver must extends DbDriver');
throw new GeneralException('Database driver must extends DbDriver');
}
self::$connections[$name] = $connection;
}

View File

@ -40,7 +40,7 @@ abstract class DbDriver
$required = array('database', 'username', 'password', 'hostname');
foreach ($required as $option) {
if (!isset($config[$option])) {
throw new Exception('Configuration must have a "' . $option . '".');
throw new GeneralException('Configuration must have a "' . $option . '".');
}
}
}

View File

@ -41,10 +41,10 @@ abstract class DbStatement
}
if (count($this->map) > 0) {
if (!is_string($param) && !is_int($param)) {
throw new Exception('Placeholder must be an array or string');
throw new GeneralException('Placeholder must be an array or string');
}
if (is_object($value) && ! ($value instanceof DbExpr)) {
throw new Exception('Objects excepts DbExpr not allowed.');
throw new GeneralException('Objects excepts DbExpr not allowed.');
}
if (isset($this->map[$param])) {
$this->params[$param] = &$value;

View File

@ -80,7 +80,7 @@ class MySQLiDriver extends DbDriver
$port);
// Connection errors check
if (mysqli_connect_error()) {
throw new Exception(mysqli_connect_error(), mysqli_connect_errno());
throw new GeneralException(mysqli_connect_error(), mysqli_connect_errno());
}
$charset = (!empty($this->config['charset'])) ? $this->config['charset'] : 'utf8';

View File

@ -43,7 +43,7 @@ class MySQLiStatement extends DbStatement
$row = $this->result->fetch_array(MYSQLI_BOTH);
break;
default:
throw new Exception('Invalid fetch mode "' . $style . '" specified');
throw new GeneralException('Invalid fetch mode "' . $style . '" specified');
}
return $row;
}
@ -92,7 +92,7 @@ class MySQLiStatement extends DbStatement
}
if ($result === false) {
$message = $mysqli->error . "\nQuery: \"" . $sql . '"';
throw new Exception($message, $mysqli->errno);
throw new GeneralException($message, $mysqli->errno);
}
if ($result instanceof MySQLi_Result) {
$this->result = $result;