]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/config/ConfigManager.php
Proper error if the conf file is invalid instead of fatal error
[github/shaarli/Shaarli.git] / application / config / ConfigManager.php
index 679a75b3bf2523eda94f9ba52b04edb84d48c717..e98af8ab0fe5c8892b36bca44715c499e252e20f 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 namespace Shaarli\Config;
 
+use Shaarli\Config\Exception\MissingFieldConfigException;
+use Shaarli\Config\Exception\UnauthorizedConfigException;
+
 /**
  * Class ConfigManager
  *
@@ -78,7 +81,11 @@ class ConfigManager
      */
     protected function load()
     {
-        $this->loadedConfig = $this->configIO->read($this->getConfigFileExt());
+        try {
+            $this->loadedConfig = $this->configIO->read($this->getConfigFileExt());
+        } catch (\Exception $e) {
+            die($e->getMessage());
+        }
         $this->setDefaultValues();
     }
 
@@ -358,36 +365,3 @@ class ConfigManager
         $this->configIO = $configIO;
     }
 }
-
-/**
- * Exception used if a mandatory field is missing in given configuration.
- */
-class MissingFieldConfigException extends \Exception
-{
-    public $field;
-
-    /**
-     * Construct exception.
-     *
-     * @param string $field field name missing.
-     */
-    public function __construct($field)
-    {
-        $this->field = $field;
-        $this->message = 'Configuration value is required for '. $this->field;
-    }
-}
-
-/**
- * Exception used if an unauthorized attempt to edit configuration has been made.
- */
-class UnauthorizedConfigException extends \Exception
-{
-    /**
-     * Construct exception.
-     */
-    public function __construct()
-    {
-        $this->message = 'You are not authorized to alter config.';
-    }
-}