MINOR: Improved some exception handling.

This commit is contained in:
Sam Minnee 2011-03-21 20:01:28 +13:00
parent 0ba86971e2
commit f83abe416c
2 changed files with 6 additions and 2 deletions

View File

@ -725,7 +725,7 @@ abstract class SS_Database {
$limit = $sqlQuery->limit;
// Pass limit as array or SQL string value
if(is_array($limit)) {
if(!array_key_exists('limit',$limit)) user_error('SQLQuery::limit(): Wrong format for $limit', E_USER_ERROR);
if(!array_key_exists('limit',$limit)) throw new InvalidArgumentException('SQLQuery::limit(): Wrong format for $limit: ' . var_export($limit, true));
if(isset($limit['start']) && is_numeric($limit['start']) && isset($limit['limit']) && is_numeric($limit['limit'])) {
$combinedLimit = $limit['start'] ? "$limit[limit] OFFSET $limit[start]" : "$limit[limit]";

View File

@ -480,7 +480,11 @@ class SQLQuery {
* @return string
*/
function __toString() {
try {
return $this->sql();
} catch(Exception $e) {
return "<sql query>";
}
}
/**