1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-20 23:41:29 +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

@@ -0,0 +1,21 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\di\exception;
use phpbb\exception\runtime_exception;
class di_exception extends runtime_exception
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace phpbb\di\exception;
class multiple_service_definitions_exception extends di_exception
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace phpbb\di\exception;
class service_not_found_exception extends di_exception
{
}

View File

@@ -13,6 +13,8 @@
namespace phpbb\di;
use phpbb\di\exception\multiple_service_definitions_exception;
use phpbb\di\exception\service_not_found_exception;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -105,7 +107,7 @@ class service_collection extends \ArrayObject
{
if ($service_id !== null)
{
throw new \RuntimeException('More than one service definitions found for class "'.$class.'" in collection.');
throw new multiple_service_definitions_exception('DI_MULTIPLE_SERVICE_DEFINITIONS', [$class]);
}
$service_id = $id;
@@ -114,7 +116,7 @@ class service_collection extends \ArrayObject
if ($service_id === null)
{
throw new \RuntimeException('No service found for class "'.$class.'" in collection.');
throw new service_not_found_exception('DI_SERVICE_NOT_FOUND', [$class]);
}
return $this->offsetGet($service_id);