Add Exception code in dblayer

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1701 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-08-11 14:59:17 +00:00
parent 96be9dfc1b
commit 33e87e33de

View File

@@ -64,7 +64,7 @@ class dblayer extends PDO
public function databasename ()
{
if ($this->db === null)
throw new Exception (dgettext("domframework", "Database not connected"));
throw new Exception (dgettext("domframework", "Database not connected"), 500);
$vals = explode (";", substr (strstr ($this->dsn, ":"), 1));
$dsnExplode = array ();
foreach ($vals as $val)
@@ -81,7 +81,7 @@ class dblayer extends PDO
public function listTables ()
{
if ($this->db === null)
throw new Exception (dgettext("domframework", "Database not connected"));
throw new Exception (dgettext("domframework", "Database not connected"), 500);
switch ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME))
{
case "sqlite":
@@ -114,7 +114,7 @@ class dblayer extends PDO
break;
default:
throw new Exception (dgettext("domframework",
"Unknown database driver in listTables"));
"Unknown database driver in listTables"), 500);
}
return $res;
}
@@ -151,7 +151,7 @@ class dblayer extends PDO
}
catch (Exception $e)
{
throw new Exception ("PDO error : ".$e->getMessage());
throw new Exception ("PDO error : ".$e->getMessage(), 500);
}
// Force specifics initialisations
@@ -735,7 +735,7 @@ class dblayer extends PDO
public function createTable ()
{
if ($this->db === null)
throw new Exception (_("Database not connected"));
throw new Exception (_("Database not connected"), 500);
switch ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME))
{
case "sqlite":
@@ -761,7 +761,7 @@ class dblayer extends PDO
break;
case "varchar":
if (!isset ($params[1]))
throw new Exception (_("No Size provided for varchar field"));
throw new Exception (_("No Size provided for varchar field"), 500);
$sql .= "VARCHAR(".$params[1].")";
$params = array_slice ($params, 2);
break;
@@ -803,7 +803,7 @@ class dblayer extends PDO
{
if (!is_array ($this->unique))
throw new Exception (
_("The Unique field definition is not an array"));
_("The Unique field definition is not an array"), 500);
foreach ($this->unique as $u)
{
$sql .= ",\n UNIQUE (`";
@@ -839,7 +839,7 @@ class dblayer extends PDO
$sql .= "`$field` ";
// Type of field : in $params[0]
if (!isset ($params[0]))
throw new Exception (_("No database type defined for field"));
throw new Exception (_("No database type defined for field"), 500);
switch ($params[0])
{
case "integer":
@@ -848,7 +848,7 @@ class dblayer extends PDO
break;
case "varchar":
if (!isset ($params[1]))
throw new Exception (_("No Size provided for varchar field"));
throw new Exception (_("No Size provided for varchar field"), 500);
$sql .= "VARCHAR(".$params[1].")";
$params = array_slice ($params, 2);
break;