1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-13 20:24:08 +02:00

[ticket/12683] Improve exception handling

PHPBB3-12683
This commit is contained in:
Ruben Calvo
2022-12-10 00:23:44 +01:00
parent 1c191868de
commit 8cea785f36
11 changed files with 54 additions and 17 deletions

View File

@@ -14,10 +14,10 @@
namespace phpbb\search;
use phpbb\config\config;
use phpbb\di\exception\service_not_found_exception;
use phpbb\di\service_collection;
use phpbb\search\backend\search_backend_interface;
use phpbb\search\exception\no_search_backend_found_exception;
use RuntimeException;
class search_backend_factory
{
@@ -58,16 +58,9 @@ class search_backend_factory
{
$search = $this->search_backends->get_by_class($class);
}
catch (RuntimeException $e)
catch (service_not_found_exception $e)
{
if (strpos($e->getMessage(), 'No service found') === 0)
{
throw new no_search_backend_found_exception();
}
else
{
throw $e;
}
throw new no_search_backend_found_exception('SEARCH_BACKEND_NOT_FOUND', [], $e);
}
return $search;

View File

@@ -113,7 +113,7 @@ class state_helper
// Make sure the action is correct (just in case)
if (!in_array($action, ['create', 'delete']))
{
throw new search_exception('Invalid action');
throw new search_exception('INVALID_ACTION');
}
$state = [