Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 883bf90

Browse files
committed
merged branch hason/di_exceptions (PR #7313)
This PR was merged into the master branch. Discussion ---------- [DependencyInjection] Added missing support for setting previous exception | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 9b4cd73 [DependencyInjection] Added missing support for setting previous exception
2 parents 38fd9d9 + 9b4cd73 commit 883bf90

7 files changed

+15
-13
lines changed

src/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class InactiveScopeException extends RuntimeException
2121
private $serviceId;
2222
private $scope;
2323

24-
public function __construct($serviceId, $scope)
24+
public function __construct($serviceId, $scope, \Exception $previous = null)
2525
{
26-
parent::__construct(sprintf('You cannot create a service ("%s") of an inactive scope ("%s").', $serviceId, $scope));
26+
parent::__construct(sprintf('You cannot create a service ("%s") of an inactive scope ("%s").', $serviceId, $scope), 0, $previous);
2727

2828
$this->serviceId = $serviceId;
2929
$this->scope = $scope;

src/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class ParameterCircularReferenceException extends RuntimeException
2020
{
2121
private $parameters;
2222

23-
public function __construct($parameters)
23+
public function __construct($parameters, \Exception $previous = null)
2424
{
25-
parent::__construct(sprintf('Circular reference detected for parameter "%s" ("%s" > "%s").', $parameters[0], implode('" > "', $parameters), $parameters[0]));
25+
parent::__construct(sprintf('Circular reference detected for parameter "%s" ("%s" > "%s").', $parameters[0], implode('" > "', $parameters), $parameters[0]), 0, $previous);
2626

2727
$this->parameters = $parameters;
2828
}

src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ class ParameterNotFoundException extends InvalidArgumentException
2929
* @param string $sourceId The service id that references the non-existent parameter
3030
* @param string $sourceKey The parameter key that references the non-existent parameter
3131
*/
32-
public function __construct($key, $sourceId = null, $sourceKey = null)
32+
public function __construct($key, $sourceId = null, $sourceKey = null, \Exception $previous = null)
3333
{
3434
$this->key = $key;
3535
$this->sourceId = $sourceId;
3636
$this->sourceKey = $sourceKey;
3737

38+
parent::__construct('', 0, $previous);
39+
3840
$this->updateRepr();
3941
}
4042

src/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ScopeCrossingInjectionException extends RuntimeException
2323
private $destServiceId;
2424
private $destScope;
2525

26-
public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope)
26+
public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null)
2727
{
2828
parent::__construct(sprintf(
2929
'Scope Crossing Injection detected: The definition "%s" references the service "%s" which belongs to another scope hierarchy. '
@@ -35,7 +35,7 @@ public function __construct($sourceServiceId, $sourceScope, $destServiceId, $des
3535
$destScope,
3636
$sourceScope,
3737
$destScope
38-
));
38+
), 0, $previous);
3939

4040
$this->sourceServiceId = $sourceServiceId;
4141
$this->sourceScope = $sourceScope;

src/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ScopeWideningInjectionException extends RuntimeException
2323
private $destServiceId;
2424
private $destScope;
2525

26-
public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope)
26+
public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null)
2727
{
2828
parent::__construct(sprintf(
2929
'Scope Widening Injection detected: The definition "%s" references the service "%s" which belongs to a narrower scope. '
@@ -34,7 +34,7 @@ public function __construct($sourceServiceId, $sourceScope, $destServiceId, $des
3434
$sourceServiceId,
3535
$destScope,
3636
$destServiceId
37-
));
37+
), 0, $previous);
3838

3939
$this->sourceServiceId = $sourceServiceId;
4040
$this->sourceScope = $sourceScope;

src/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class ServiceCircularReferenceException extends RuntimeException
2121
private $serviceId;
2222
private $path;
2323

24-
public function __construct($serviceId, array $path)
24+
public function __construct($serviceId, array $path, \Exception $previous = null)
2525
{
26-
parent::__construct(sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, implode(' -> ', $path)));
26+
parent::__construct(sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, implode(' -> ', $path)), 0, $previous);
2727

2828
$this->serviceId = $serviceId;
2929
$this->path = $path;

src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class ServiceNotFoundException extends InvalidArgumentException
2121
private $id;
2222
private $sourceId;
2323

24-
public function __construct($id, $sourceId = null)
24+
public function __construct($id, $sourceId = null, \Exception $previous = null)
2525
{
2626
if (null === $sourceId) {
2727
$msg = sprintf('You have requested a non-existent service "%s".', $id);
2828
} else {
2929
$msg = sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id);
3030
}
3131

32-
parent::__construct($msg);
32+
parent::__construct($msg, 0, $previous);
3333

3434
$this->id = $id;
3535
$this->sourceId = $sourceId;

0 commit comments

Comments
 (0)