Chris@14: Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: namespace Symfony\Component\DependencyInjection\Compiler; Chris@14: Chris@14: use Symfony\Component\DependencyInjection\Definition; Chris@14: use Symfony\Component\DependencyInjection\Exception\RuntimeException; Chris@14: Chris@14: /** Chris@14: * Throws an exception for any Definitions that have errors and still exist. Chris@14: * Chris@14: * @author Ryan Weaver Chris@14: */ Chris@14: class DefinitionErrorExceptionPass extends AbstractRecursivePass Chris@14: { Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: protected function processValue($value, $isRoot = false) Chris@14: { Chris@14: if (!$value instanceof Definition || empty($value->getErrors())) { Chris@14: return parent::processValue($value, $isRoot); Chris@14: } Chris@14: Chris@14: // only show the first error so the user can focus on it Chris@14: $errors = $value->getErrors(); Chris@14: $message = reset($errors); Chris@14: Chris@14: throw new RuntimeException($message); Chris@14: } Chris@14: }