Skip to content

Commit

Permalink
Remove LogException and CacheException
Browse files Browse the repository at this point in the history
Both these exception classes have very few callers and really don't
offer the end user any additional information beyond a type.
  • Loading branch information
markstory committed Sep 18, 2012
1 parent c023efa commit 669ab20
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 76 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Cache/Cache.php
Expand Up @@ -142,7 +142,7 @@ public static function config($name = null, $settings = array()) {
*
* @param string $name Name of the config array that needs an engine instance built
* @return boolean
* @throws CacheException
* @throws Cake\Error\Exception
*/
protected static function _buildEngine($name) {
$config = Configure::read('Cache.' . $name);
Expand All @@ -154,7 +154,7 @@ protected static function _buildEngine($name) {
return false;
}
if (!is_subclass_of($cacheClass, 'Cake\Cache\CacheEngine')) {
throw new Error\CacheException(__d('cake_dev', 'Cache engines must use Cake\Cache\CacheEngine as a base class.'));
throw new Error\Exception(__d('cake_dev', 'Cache engines must use Cake\Cache\CacheEngine as a base class.'));
}
$engine = new $cacheClass();
if ($engine->init($config)) {
Expand Down
28 changes: 0 additions & 28 deletions lib/Cake/Error/CacheException.php

This file was deleted.

28 changes: 0 additions & 28 deletions lib/Cake/Error/LogException.php

This file was deleted.

14 changes: 7 additions & 7 deletions lib/Cake/Log/Log.php
Expand Up @@ -206,7 +206,7 @@ public static function reset() {
* logger later.
* @param array $config Array of configuration information for the logger
* @return boolean success of configuration.
* @throws Cake\Error\LogException
* @throws Cake\Error\Exception
*/
public static function config($key, $config) {
trigger_error(
Expand Down Expand Up @@ -254,12 +254,12 @@ public static function drop($streamName) {
*
* @param string $streamName to check
* @return bool
* @throws Cake\Error\LogException
* @throws Cake\Error\Exception
*/
public static function enabled($streamName) {
static::_init();
if (!isset(static::$_Collection->{$streamName})) {
throw new Error\LogException(__d('cake_dev', 'Stream %s not found', $streamName));
throw new Error\Exception(__d('cake_dev', 'Stream %s not found', $streamName));
}
return static::$_Collection->enabled($streamName);
}
Expand All @@ -270,12 +270,12 @@ public static function enabled($streamName) {
*
* @param string $streamName to enable
* @return void
* @throws Cake\Error\LogException
* @throws Cake\Error\Exception
*/
public static function enable($streamName) {
static::_init();
if (!isset(static::$_Collection->{$streamName})) {
throw new Error\LogException(__d('cake_dev', 'Stream %s not found', $streamName));
throw new Error\Exception(__d('cake_dev', 'Stream %s not found', $streamName));
}
static::$_Collection->enable($streamName);
}
Expand All @@ -287,12 +287,12 @@ public static function enable($streamName) {
*
* @param string $streamName to disable
* @return void
* @throws Cake\Error\LogException
* @throws Cake\Error\Exception
*/
public static function disable($streamName) {
static::_init();
if (!isset(static::$_Collection->{$streamName})) {
throw new Error\LogException(__d('cake_dev', 'Stream %s not found', $streamName));
throw new Error\Exception(__d('cake_dev', 'Stream %s not found', $streamName));
}
static::$_Collection->disable($streamName);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Log/LogEngineCollection.php
Expand Up @@ -32,7 +32,7 @@ class LogEngineCollection extends ObjectCollection {
* @param LogInterface|array $options Setting for the Log Engine, or the log engine
* If a log engine is used, the adapter will be enabled.
* @return BaseLog BaseLog engine instance
* @throws Cake\Error\LogException when logger class does not implement a write method
* @throws Cake\Error\Exception when logger class does not implement a write method
*/
public function load($name, $options = array()) {
$logger = false;
Expand All @@ -46,7 +46,7 @@ public function load($name, $options = array()) {
$logger = $this->_getLogger($options);
}
if (!$logger instanceof LogInterface) {
throw new Error\LogException(sprintf(
throw new Error\Exception(sprintf(
__d('cake_dev', 'logger class %s is not an instance of Cake\Log\LogInterface.'), $name
));
}
Expand All @@ -70,7 +70,7 @@ protected static function _getLogger($options) {
unset($options['engine']);
$class = App::classname($name, 'Log/Engine');
if (!$class) {
throw new Error\LogException(__d('cake_dev', 'Could not load class %s', $name));
throw new Error\Exception(__d('cake_dev', 'Could not load class %s', $name));
}
$logger = new $class($options);
return $logger;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/TestCase/Cache/CacheTest.php
Expand Up @@ -148,7 +148,7 @@ public function testDecrementNonExistingConfig() {
/**
* test that trying to configure classes that don't extend CacheEngine fail.
*
* @expectedException Cake\Error\CacheException
* @expectedException Cake\Error\Exception
* @return void
*/
public function testAttemptingToConfigureANonCacheEngineClass() {
Expand Down
14 changes: 7 additions & 7 deletions lib/Cake/Test/TestCase/Log/LogTest.php
Expand Up @@ -76,7 +76,7 @@ public function testImportingLoggers() {
/**
* test all the errors from failed logger imports
*
* @expectedException Cake\Error\LogException
* @expectedException Cake\Error\Exception
* @return void
*/
public function testImportingLoggerFailure() {
Expand All @@ -98,7 +98,7 @@ public function testValidKeyName() {
/**
* test that loggers have to implement the correct interface.
*
* @expectedException Cake\Error\LogException
* @expectedException Cake\Error\Exception
* @return void
*/
public function testNotImplementingInterface() {
Expand Down Expand Up @@ -130,7 +130,7 @@ public function testDrop() {
* Test that engine() throws an exception when adding an
* adapter with the wrong type.
*
* @expectedException Cake\Error\LogException
* @expectedException Cake\Error\Exception
* @return void
*/
public function testEngineInjectErrorOnWrongType() {
Expand Down Expand Up @@ -219,7 +219,7 @@ public function testSelectiveLoggingByLevel() {
/**
* test enable
*
* @expectedException Cake\Error\LogException
* @expectedException Cake\Error\Exception
*/
public function testStreamEnable() {
Configure::write('Log.spam', array(
Expand All @@ -234,7 +234,7 @@ public function testStreamEnable() {
/**
* test disable
*
* @expectedException Cake\Error\LogException
* @expectedException Cake\Error\Exception
*/
public function testStreamDisable() {
Configure::write('Log.spam', array(
Expand All @@ -251,7 +251,7 @@ public function testStreamDisable() {
/**
* test enabled() invalid stream
*
* @expectedException Cake\Error\LogException
* @expectedException Cake\Error\Exception
*/
public function testStreamEnabledInvalid() {
Log::enabled('bogus_stream');
Expand All @@ -260,7 +260,7 @@ public function testStreamEnabledInvalid() {
/**
* test disable invalid stream
*
* @expectedException Cake\Error\LogException
* @expectedException Cake\Error\Exception
*/
public function testStreamDisableInvalid() {
Log::disable('bogus_stream');
Expand Down

0 comments on commit 669ab20

Please sign in to comment.