Skip to content

Commit

Permalink
Clean up Exception formatting. Refs #3927
Browse files Browse the repository at this point in the history
  • Loading branch information
cbandy committed Apr 17, 2011
1 parent 539c81c commit 1d9c6dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
9 changes: 4 additions & 5 deletions classes/kohana/database/mysql.php
Expand Up @@ -64,9 +64,8 @@ public function connect()
// No connection exists
$this->_connection = NULL;

throw new Database_Exception(':error', array(
':error' => mysql_error(),
),
throw new Database_Exception(':error',
array(':error' => mysql_error()),
mysql_errno());
}

Expand Down Expand Up @@ -371,8 +370,8 @@ public function escape($value)
if (($value = mysql_real_escape_string( (string) $value, $this->_connection)) === FALSE)
{
throw new Database_Exception(':error',
array(':error' => mysql_errno($this->_connection)),
mysql_error($this->_connection));
array(':error' => mysql_error($this->_connection)),
mysql_errno($this->_connection));
}

// SQL standard is to use single-quotes for all values
Expand Down
14 changes: 6 additions & 8 deletions classes/kohana/database/pdo.php
Expand Up @@ -56,11 +56,9 @@ public function connect()
}
catch (PDOException $e)
{
throw new Database_Exception(':error', array(
':error' => $e->getMessage(),
),
$e->getCode(),
$e);
throw new Database_Exception(':error',
array(':error' => $e->getMessage()),
$e->getCode());
}

if ( ! empty($this->_config['charset']))
Expand Down Expand Up @@ -111,12 +109,12 @@ public function query($type, $sql, $as_object = FALSE, array $params = NULL)
}

// Convert the exception in a database exception
throw new Database_Exception(':error [ :query ]', array(
throw new Database_Exception(':error [ :query ]',
array(
':error' => $e->getMessage(),
':query' => $sql
),
$e->getCode(),
$e);
$e->getCode());
}

if (isset($benchmark))
Expand Down

0 comments on commit 1d9c6dc

Please sign in to comment.