Skip to content

Commit

Permalink
Fixes #7356 Do not catch and silence exceptions blindly
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Mar 10, 2015
1 parent 42da3f8 commit 3850551
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Piwik;

use Exception;
use Piwik\Config\ConfigNotFoundException;
use Piwik\Ini\IniReader;
use Piwik\Ini\IniReadingException;
use Piwik\Ini\IniWriter;
Expand Down Expand Up @@ -370,7 +371,7 @@ public function deleteLocalConfig()
public function checkLocalConfigFound()
{
if (!$this->existsLocalConfig()) {
throw new Exception(Piwik::translate('General_ExceptionConfigurationFileNotFound', array($this->pathLocal)));
throw new ConfigNotFoundException(Piwik::translate('General_ExceptionConfigurationFileNotFound', array($this->pathLocal)));
}
}

Expand Down
16 changes: 16 additions & 0 deletions core/Config/ConfigNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Config;

/**
* Exception thrown when the config file doesn't exist.
*/
class ConfigNotFoundException extends \Exception
{
}
6 changes: 3 additions & 3 deletions core/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
namespace Piwik;

use Piwik\Config\ConfigNotFoundException;
use Piwik\Container\StaticContainer;
use Piwik\Plugin\Manager as PluginManager;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
Expand Down Expand Up @@ -43,10 +44,9 @@ public function doRun(InputInterface $input, OutputInterface $output)

try {
self::initPlugins();
} catch(\Exception $e) {
} catch (ConfigNotFoundException $e) {
// Piwik not installed yet, no config file?
Log::debug("Could not initialize plugins: " . $e->getMessage() . "\n" . $e->getTraceAsString());
Log::warning($e->getMessage());
}

$commands = $this->getAvailableCommands();
Expand Down

0 comments on commit 3850551

Please sign in to comment.