From 5ba55f0cf287c583019bbb731ad98e04a14da972 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 8 Mar 2017 20:28:33 +0100 Subject: Move config exception to dedicated classes with proper namespace --- application/config/ConfigManager.php | 36 ++-------------------- .../exception/MissingFieldConfigException.php | 23 ++++++++++++++ .../exception/UnauthorizedConfigException.php | 18 +++++++++++ 3 files changed, 44 insertions(+), 33 deletions(-) create mode 100644 application/config/exception/MissingFieldConfigException.php create mode 100644 application/config/exception/UnauthorizedConfigException.php (limited to 'application') diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index 679a75b3..f2097410 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php @@ -1,6 +1,9 @@ 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.'; - } -} diff --git a/application/config/exception/MissingFieldConfigException.php b/application/config/exception/MissingFieldConfigException.php new file mode 100644 index 00000000..6346c6a9 --- /dev/null +++ b/application/config/exception/MissingFieldConfigException.php @@ -0,0 +1,23 @@ +field = $field; + $this->message = 'Configuration value is required for '. $this->field; + } +} diff --git a/application/config/exception/UnauthorizedConfigException.php b/application/config/exception/UnauthorizedConfigException.php new file mode 100644 index 00000000..79672c1b --- /dev/null +++ b/application/config/exception/UnauthorizedConfigException.php @@ -0,0 +1,18 @@ +message = 'You are not authorized to alter config.'; + } +} -- cgit v1.2.3