From 0f88a93218e95e08d9d94223a264ae45b73c502e Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko <sshkolyarenko@magento.com> Date: Tue, 1 Mar 2016 15:23:58 +0200 Subject: [PATCH] MAGETWO-43267: Exceptions are displayed on Storefront in default mode changed exception --- .../Magento/Framework/Code/Generator.php | 17 +++++++---------- .../Framework/Code/Test/Unit/GeneratorTest.php | 4 ++-- .../Test/Unit/Relations/RuntimeTest.php | 2 +- .../Setup/Module/Di/Code/Scanner/PhpScanner.php | 2 +- .../Setup/Module/Di/Code/Scanner/XmlScanner.php | 2 +- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/internal/Magento/Framework/Code/Generator.php b/lib/internal/Magento/Framework/Code/Generator.php index 92057208769..f88025212b7 100644 --- a/lib/internal/Magento/Framework/Code/Generator.php +++ b/lib/internal/Magento/Framework/Code/Generator.php @@ -81,7 +81,7 @@ class Generator * * @param string $className * @return string | void - * @throws \Magento\Framework\Exception\LocalizedException + * @throws \RuntimeException * @throws \InvalidArgumentException */ public function generateClass($className) @@ -112,9 +112,7 @@ class Generator $this->tryToLoadSourceClass($className, $generator); if (!($file = $generator->generate())) { $errors = $generator->getErrors(); - throw new \Magento\Framework\Exception\LocalizedException( - new \Magento\Framework\Phrase(implode(' ', $errors)) - ); + throw new \RuntimeException(implode(' ', $errors)); } if (!$this->definedClasses->isClassLoadableFromMemory($className)) { $this->_ioObject->includeFile($file); @@ -173,19 +171,18 @@ class Generator * @param string $className * @param \Magento\Framework\Code\Generator\EntityAbstract $generator * @return void - * @throws \Magento\Framework\Exception\LocalizedException + * @throws \RuntimeException */ protected function tryToLoadSourceClass($className, $generator) { $sourceClassName = $generator->getSourceClassName(); if (!$this->definedClasses->isClassLoadable($sourceClassName)) { if ($this->generateClass($sourceClassName) !== self::GENERATION_SUCCESS) { - throw new \Magento\Framework\Exception\LocalizedException( - new \Magento\Framework\Phrase( - 'Source class "%1" for "%2" generation does not exist.', - [$sourceClassName, $className] - ) + $phrase = new \Magento\Framework\Phrase( + 'Source class "%1" for "%2" generation does not exist.', + [$sourceClassName, $className] ); + throw new \RuntimeException($phrase->__toString()); } } } diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php index c289ba47967..afcf1072e87 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php @@ -71,7 +71,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedException \RuntimeException * @dataProvider generateValidClassDataProvider */ public function testGenerateClass($className, $entityType) @@ -95,7 +95,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedException \RuntimeException */ public function testGenerateClassWithError() { diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php index 2485e8e1562..8195a4f5f19 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php @@ -42,7 +42,7 @@ class RuntimeTest extends \PHPUnit_Framework_TestCase /** * @param $entity - * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedException \RuntimeException * @dataProvider nonExistentGeneratorsDataProvider */ public function testHasIfNonExists($entity) diff --git a/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php index d46cbe86b29..bfce36a8cac 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php @@ -49,7 +49,7 @@ class PhpScanner implements ScannerInterface if (class_exists($missingClassName)) { continue; } - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (\RuntimeException $e) { } $sourceClassName = $this->getSourceClassName($missingClassName, $entityType); if (!class_exists($sourceClassName) && !interface_exists($sourceClassName)) { diff --git a/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php index adc5a452ca9..2c0c4ed5915 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php @@ -68,7 +68,7 @@ class XmlScanner implements ScannerInterface $isClassExists = false; try { $isClassExists = class_exists($className); - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (\RuntimeException $e) { } if (false === $isClassExists) { if (class_exists($entityName) || interface_exists($entityName)) { -- GitLab