mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-04 10:32:40 +00:00
Making all core classes throw CakeException subclasses, this allows developers to catch framework exceptions with one catch.
Adding package specific exceptions. Replacing generic exceptions in the codebase with CakeException + package exceptions.
This commit is contained in:
parent
6c0efb62e7
commit
44c080d5ad
28 changed files with 146 additions and 86 deletions
|
@ -97,18 +97,18 @@ class CakeLog {
|
|||
* @param string $key The keyname for this logger, used to remove the logger later.
|
||||
* @param array $config Array of configuration information for the logger
|
||||
* @return boolean success of configuration.
|
||||
* @throws Exception
|
||||
* @throws CakeLogException
|
||||
*/
|
||||
public static function config($key, $config) {
|
||||
if (empty($config['engine'])) {
|
||||
throw new Exception(__('Missing logger classname'));
|
||||
throw new CakeLogException(__('Missing logger classname'));
|
||||
}
|
||||
$loggerName = $config['engine'];
|
||||
unset($config['engine']);
|
||||
$className = self::_getLogger($loggerName);
|
||||
$logger = new $className($config);
|
||||
if (!$logger instanceof CakeLogInterface) {
|
||||
throw new Exception(sprintf(
|
||||
throw new CakeLogException(sprintf(
|
||||
__('logger class %s does not implement a write method.'), $loggerName
|
||||
));
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ class CakeLog {
|
|||
}
|
||||
}
|
||||
if (!class_exists($loggerName)) {
|
||||
throw new Exception(__('Could not load class %s', $loggerName));
|
||||
throw new CakeLogException(__('Could not load class %s', $loggerName));
|
||||
}
|
||||
return $loggerName;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue