From 9b4cd737482f7524121b265dac20c1d03b357919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Fri, 8 Mar 2013 10:15:11 +0100 Subject: [PATCH] [DependencyInjection] Added missing support for setting previous exception --- .../DependencyInjection/Exception/InactiveScopeException.php | 4 ++-- .../Exception/ParameterCircularReferenceException.php | 4 ++-- .../Exception/ParameterNotFoundException.php | 4 +++- .../Exception/ScopeCrossingInjectionException.php | 4 ++-- .../Exception/ScopeWideningInjectionException.php | 4 ++-- .../Exception/ServiceCircularReferenceException.php | 4 ++-- .../Exception/ServiceNotFoundException.php | 4 ++-- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php b/src/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php index 24d1ca0547f7d..6b3dd3ebb1acd 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/InactiveScopeException.php @@ -21,9 +21,9 @@ class InactiveScopeException extends RuntimeException private $serviceId; private $scope; - public function __construct($serviceId, $scope) + public function __construct($serviceId, $scope, \Exception $previous = null) { - parent::__construct(sprintf('You cannot create a service ("%s") of an inactive scope ("%s").', $serviceId, $scope)); + parent::__construct(sprintf('You cannot create a service ("%s") of an inactive scope ("%s").', $serviceId, $scope), 0, $previous); $this->serviceId = $serviceId; $this->scope = $scope; diff --git a/src/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php b/src/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php index 958ade060c653..29151765dc5b6 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php @@ -20,9 +20,9 @@ class ParameterCircularReferenceException extends RuntimeException { private $parameters; - public function __construct($parameters) + public function __construct($parameters, \Exception $previous = null) { - parent::__construct(sprintf('Circular reference detected for parameter "%s" ("%s" > "%s").', $parameters[0], implode('" > "', $parameters), $parameters[0])); + parent::__construct(sprintf('Circular reference detected for parameter "%s" ("%s" > "%s").', $parameters[0], implode('" > "', $parameters), $parameters[0]), 0, $previous); $this->parameters = $parameters; } diff --git a/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php b/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php index 200fbec2af2b6..04767bf3bec1f 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php @@ -29,12 +29,14 @@ class ParameterNotFoundException extends InvalidArgumentException * @param string $sourceId The service id that references the non-existent parameter * @param string $sourceKey The parameter key that references the non-existent parameter */ - public function __construct($key, $sourceId = null, $sourceKey = null) + public function __construct($key, $sourceId = null, $sourceKey = null, \Exception $previous = null) { $this->key = $key; $this->sourceId = $sourceId; $this->sourceKey = $sourceKey; + parent::__construct('', 0, $previous); + $this->updateRepr(); } diff --git a/src/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php b/src/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php index f23374f21085d..661fbab3697f8 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ScopeCrossingInjectionException.php @@ -23,7 +23,7 @@ class ScopeCrossingInjectionException extends RuntimeException private $destServiceId; private $destScope; - public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope) + public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null) { parent::__construct(sprintf( '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 $destScope, $sourceScope, $destScope - )); + ), 0, $previous); $this->sourceServiceId = $sourceServiceId; $this->sourceScope = $sourceScope; diff --git a/src/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php b/src/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php index d46345334ca6b..86a668419510f 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ScopeWideningInjectionException.php @@ -23,7 +23,7 @@ class ScopeWideningInjectionException extends RuntimeException private $destServiceId; private $destScope; - public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope) + public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null) { parent::__construct(sprintf( '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 $sourceServiceId, $destScope, $destServiceId - )); + ), 0, $previous); $this->sourceServiceId = $sourceServiceId; $this->sourceScope = $sourceScope; diff --git a/src/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php b/src/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php index e0000011fc756..26e3fb34bf3cb 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php @@ -21,9 +21,9 @@ class ServiceCircularReferenceException extends RuntimeException private $serviceId; private $path; - public function __construct($serviceId, array $path) + public function __construct($serviceId, array $path, \Exception $previous = null) { - parent::__construct(sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, implode(' -> ', $path))); + parent::__construct(sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, implode(' -> ', $path)), 0, $previous); $this->serviceId = $serviceId; $this->path = $path; diff --git a/src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php b/src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php index f9af1ea84e37e..b40509a4a5f09 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php @@ -21,7 +21,7 @@ class ServiceNotFoundException extends InvalidArgumentException private $id; private $sourceId; - public function __construct($id, $sourceId = null) + public function __construct($id, $sourceId = null, \Exception $previous = null) { if (null === $sourceId) { $msg = sprintf('You have requested a non-existent service "%s".', $id); @@ -29,7 +29,7 @@ public function __construct($id, $sourceId = null) $msg = sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id); } - parent::__construct($msg); + parent::__construct($msg, 0, $previous); $this->id = $id; $this->sourceId = $sourceId;