Skip to content

Commit fc96a75

Browse files
committed
introduce new exception class
1 parent a5af6a6 commit fc96a75

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Piwik\Config;
1515
use Piwik\Container\StaticContainer;
1616
use Piwik\Development;
17-
use Piwik\Http\BadRequestException;
17+
use Piwik\Exception\ThingNotFoundException;
1818
use Piwik\Plugin\Manager;
1919

2020
class PluginUmdAssetFetcher extends UIAssetFetcher
@@ -203,7 +203,7 @@ protected function retrieveFileLocations()
203203
}
204204

205205
if (!$foundChunk) {
206-
throw new BadRequestException("Could not find chunk {$this->requestedChunk}", 404);
206+
throw new ThingNotFoundException('Could not find chunk {$this->requestedChunk}');
207207
}
208208

209209
foreach ($foundChunk->getFiles() as $file) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/**
4+
* Matomo - free/libre analytics platform
5+
*
6+
* @link https://matomo.org
7+
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8+
*/
9+
10+
namespace Piwik\Exception;
11+
12+
use Piwik\Http\HttpCodeException;
13+
14+
class ThingNotFoundException extends \Piwik\Exception\Exception implements HttpCodeException
15+
{
16+
public function __construct($message, $previous = null)
17+
{
18+
parent::__construct($message, 400, $previous);
19+
}
20+
}

core/Http/ControllerResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Piwik\Http;
1111

1212
use DI\FactoryInterface;
13-
use Exception;
13+
use Piwik\Exception\ThingNotFoundException;
1414
use Piwik\Plugin\ReportsProvider;
1515
use Piwik\Plugin\WidgetsProvider;
1616

@@ -41,7 +41,7 @@ public function __construct(FactoryInterface $abstractFactory, WidgetsProvider $
4141
* @param string $module
4242
* @param string|null $action
4343
* @param array $parameters
44-
* @throws Exception Controller not found.
44+
* @throws ThingNotFoundException Controller not found.
4545
* @return callable The controller is a PHP callable.
4646
*/
4747
public function getController($module, $action, array &$parameters)
@@ -61,7 +61,7 @@ public function getController($module, $action, array &$parameters)
6161
return $controller;
6262
}
6363

64-
throw new BadRequestException(sprintf("Action '%s' not found in the module '%s'", $action, $module), 404);
64+
throw new ThingNotFoundException(sprintf("Action '%s' not found in the module '%s'", $action, $module));
6565
}
6666

6767
private function createPluginController($module, $action)

0 commit comments

Comments
 (0)