diff --git a/lib/internal/Magento/Framework/Code/Generator.php b/lib/internal/Magento/Framework/Code/Generator.php
index 92057208769f736643f05e8913ea973e8ec66f1f..f88025212b797910095b4f6f1f3631633d2401f5 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 c289ba47967435ded674df11cc9af595e280909e..afcf1072e874ccae04ec001d6e5a0e0ea49d6e1c 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 2485e8e156228c7e2206971dd890e3e125e100e7..8195a4f5f193e57a41e39ede7a1b8eec96c3c185 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 d46cbe86b291ee26eb29cf314873cbe99a09edd2..bfce36a8caca204ecaa5dbc6862424181b163b49 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 adc5a452ca9bb4bb8a96b552d9976d6a92954a17..2c0c4ed5915c3ab2290931c48357bd1339ad53ee 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)) {