From 016fac4be31f0c240ce7de930a48a4443f527a27 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Sat, 16 May 2015 14:51:53 +0000 Subject: [PATCH] config : return a Exception code when there is an error git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2183 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- config.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config.php b/config.php index 142a72a..f1b3ab6 100644 --- a/config.php +++ b/config.php @@ -54,7 +54,7 @@ class config $conf = array (); $rc = include ($this->confFile); if ($rc !== 1) - throw new Exception ("Error in configuration file"); + throw new Exception ("Error in configuration file", 500); return $conf; } @@ -65,7 +65,7 @@ class config { $this->selectConfFile (); if (!array_key_exists ($param, $this->default)) - throw new Exception ("Unknown parameter '$param'"); + throw new Exception ("Unknown parameter '$param'", 500); if (!file_exists ($this->confFile)) { if (@file_put_contents ($this->confFile, @@ -73,7 +73,7 @@ class config === FALSE) throw new Exception (sprintf (dgettext("domframework", "No configuration file '%s' available and it can't be created"), - $this->confFile)); + $this->confFile), 500); } elseif (! is_readable ($this->confFile)) throw new Exception (sprintf ( dgettext("domframework", @@ -82,7 +82,7 @@ class config $conf = array (); $rc = include ($this->confFile); if ($rc !== 1) - throw new Exception ("Error in configuration file"); + throw new Exception ("Error in configuration file", 500); if (array_key_exists ($param, $conf)) { if (! is_array ($conf[$param])) @@ -110,7 +110,7 @@ class config { $this->selectConfFile (); if (!array_key_exists ($param, $this->default)) - throw new Exception ("Unknown parameter '$param'"); + throw new Exception ("Unknown parameter '$param'", 500); if (!file_exists ($this->confFile)) { if (@file_put_contents ($this->confFile, @@ -124,11 +124,11 @@ class config throw new Exception (sprintf ( dgettext("domframework", "The configuration file '%s' is not readable"), - $this->confFile)); + $this->confFile), 500); if (!is_writeable ($this->confFile)) throw new Exception (sprintf (dgettext("domframework", "Configuration file '%s' is write protected"), - $this->confFile)); + $this->confFile), 500); $conf = array (); $rc = include ($this->confFile); if ($rc !== 1) @@ -143,7 +143,7 @@ class config if (@file_put_contents ($this->confFile, $txt, LOCK_EX) === FALSE) throw new Exception (sprintf (dgettext("domframework", "Can't save configuration file '%s'"), - $this->confFile)); + $this->confFile), 500); return TRUE; }