Skip to content
Permalink
Browse files

Update exception in log classes.

  • Loading branch information...
ADmad committed Aug 31, 2014
1 parent 63a215b commit d1610d97dc9fa40c08b7f686738da0df6ec83e2f
Showing with 17 additions and 17 deletions.
  1. +3 −2 src/Log/Engine/ConsoleLog.php
  2. +4 −4 src/Log/Log.php
  3. +5 −6 src/Log/LogEngineRegistry.php
  4. +5 −5 tests/TestCase/Log/LogTest.php
@@ -16,6 +16,7 @@
use Cake\Console\ConsoleOutput;
use Cake\Core\Exception\Exception;
use \InvalidArgumentException;
/**
* Console logging. Writes logs to console output.
@@ -52,7 +53,7 @@ class ConsoleLog extends BaseLog {
* - `outputAs` integer or ConsoleOutput::[RAW|PLAIN|COLOR]
*
* @param array $config Options for the FileLog, see above.
* @throws \Cake\Core\Exception\Exception
* @throws \InvalidArgumentException
*/
public function __construct(array $config = array()) {
if (DS === '\\' && !(bool)env('ANSICON')) {
@@ -69,7 +70,7 @@ public function __construct(array $config = array()) {
} elseif (is_string($config['stream'])) {
$this->_output = new ConsoleOutput($config['stream']);
} else {
throw new Exception('`stream` not a ConsoleOutput nor string');
throw new InvalidArgumentException('`stream` not a ConsoleOutput nor string');
}
$this->_output->outputAs($config['outputAs']);
}
@@ -14,8 +14,8 @@
namespace Cake\Log;
use Cake\Core\StaticConfigTrait;
use Cake\Core\Exception\Exception;
use Cake\Log\Engine\BaseLog;
use InvalidArgumentException;
/**
* Logs messages to configured Log adapters. One or more adapters
@@ -246,7 +246,7 @@ public static function levels() {
* @param string|array $key The name of the logger config, or an array of multiple configs.
* @param array $config An array of name => config data for adapter.
* @return mixed null when adding configuration and an array of configuration data when reading.
* @throws \Cake\Core\Exception\Exception When trying to modify an existing config.
* @throws \BadMethodCallException When trying to modify an existing config.
*/
public static function config($key, $config = null) {
$return = static::_config($key, $config);
@@ -316,7 +316,7 @@ public static function engine($name) {
* @param string|array $scope The scope(s) a log message is being created in.
* See Cake\Log\Log::config() for more information on logging scopes.
* @return bool Success
* @throws \Cake\Core\Exception\Exception If invalid level is passed.
* @throws \InvalidArgumentException If invalid level is passed.
*/
public static function write($level, $message, $scope = array()) {
static::_init();
@@ -325,7 +325,7 @@ public static function write($level, $message, $scope = array()) {
}
if (!in_array($level, static::$_levels)) {
throw new Exception(sprintf('Invalid log level "%s"', $level));
throw new InvalidArgumentException(sprintf('Invalid log level "%s"', $level));
}
$logged = false;
@@ -15,9 +15,9 @@
namespace Cake\Log;
use Cake\Core\App;
use Cake\Core\Exception\Exception;
use Cake\Core\ObjectRegistry;
use Cake\Log\LogInterface;
use \RuntimeException;
/**
* Registry of loaded log engines
@@ -48,10 +48,10 @@ protected function _resolveClassName($class) {
* @param string $class The classname that is missing.
* @param string $plugin The plugin the logger is missing in.
* @return void
* @throws \Cake\Core\Exception\Exception
* @throws \RuntimeException
*/
protected function _throwMissingClassError($class, $plugin) {
throw new Exception(sprintf('Could not load class %s', $class));
throw new RuntimeException(sprintf('Could not load class %s', $class));
}
/**
@@ -63,8 +63,7 @@ protected function _throwMissingClassError($class, $plugin) {
* @param string $alias The alias of the object.
* @param array $settings An array of settings to use for the logger.
* @return \Cake\Log\LogInterface The constructed logger class.
* @throws \Cake\Core\Exception\Exception when an object doesn't implement
* the correct interface.
* @throws \RuntimeException when an object doesn't implement the correct interface.
*/
protected function _create($class, $alias, $settings) {
if (is_object($class)) {
@@ -79,7 +78,7 @@ protected function _create($class, $alias, $settings) {
return $instance;
}
throw new Exception(
throw new RuntimeException(
'Loggers must implement Cake\Log\LogInterface.'
);
}
@@ -69,7 +69,7 @@ public function testImportingLoggers() {
/**
* test all the errors from failed logger imports
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException RuntimeException
* @return void
*/
public function testImportingLoggerFailure() {
@@ -91,7 +91,7 @@ public function testValidKeyName() {
/**
* test that loggers have to implement the correct interface.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException \RuntimeException
* @return void
*/
public function testNotImplementingInterface() {
@@ -122,7 +122,7 @@ public function testDrop() {
/**
* test config() with valid key name
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException \InvalidArgumentException
* @return void
*/
public function testInvalidLevel() {
@@ -166,7 +166,7 @@ public function testConfigVariants($settings) {
* Test that config() throws an exception when adding an
* adapter with the wrong type.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException \RuntimeException
* @return void
*/
public function testConfigInjectErrorOnWrongType() {
@@ -195,7 +195,7 @@ public function testConfigRead() {
/**
* Ensure you cannot reconfigure a log adapter.
*
* @expectedException BadMethodCallException
* @expectedException \BadMethodCallException
* @return void
*/
public function testConfigErrorOnReconfigure() {

0 comments on commit d1610d9

Please sign in to comment.
You can’t perform that action at this time.