Add and improve custom exception types for all cases

This commit is contained in:
Dale Davies
2022-07-26 14:35:10 +01:00
parent 5b9fe67021
commit d3dc11fdf3
8 changed files with 80 additions and 21 deletions

View File

@@ -13,7 +13,7 @@
namespace Jump;
use Exception;
use Jump\Exceptions\ConfigException;
/**
* Load, parse and enumerate all configuration paramaters requires throughout
@@ -67,7 +67,7 @@ class Config {
$this->add_wwwroot_to_base_paths();
$this->add_session_config();
if ($this->config_params_missing()) {
throw new Exception('Config.php must always contain... '.implode(', ', self::CONFIG_PARAMS));
throw new ConfigException('Config.php must always contain... '.implode(', ', self::CONFIG_PARAMS));
}
}
@@ -115,7 +115,7 @@ class Config {
*/
public function get(string $key, $strict = true): mixed {
if (!$this->config->has($key) && $strict === true) {
throw new Exception('Config key does not exist... ('.$key.')');
throw new ConfigException('Config key does not exist... ('.$key.')');
}
return $this->config->get($key);
}