From a630ba3a2b295a97b8a579608c6fad6a510a0064 Mon Sep 17 00:00:00 2001 From: Shambhu Kumar Date: Mon, 11 Dec 2023 21:10:42 +0530 Subject: [PATCH 1/2] Throw \Exception when ContentProcessorException raised to avoid deployement success --- app/code/Magento/Deploy/Service/DeployPackage.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Deploy/Service/DeployPackage.php b/app/code/Magento/Deploy/Service/DeployPackage.php index 0522702cbdc2b..34928aeec0a24 100644 --- a/app/code/Magento/Deploy/Service/DeployPackage.php +++ b/app/code/Magento/Deploy/Service/DeployPackage.php @@ -136,6 +136,7 @@ public function deployEmulated(Package $package, array $options, $skipLogging = . PHP_EOL . $exception->getMessage(); $this->errorsCount++; $this->logger->critical($errorMessage); + throw new \Exception($errorMessage); } catch (\Exception $exception) { $this->logger->critical($exception->getTraceAsString()); $this->errorsCount++; From 7419958f9164958e0d8e9fbb12924116a61cfecf Mon Sep 17 00:00:00 2001 From: Shambhu Kumar Date: Fri, 15 Dec 2023 23:11:07 +0530 Subject: [PATCH 2/2] fix: Direct throw of generic Exception is discouraged --- app/code/Magento/Deploy/Service/DeployPackage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Deploy/Service/DeployPackage.php b/app/code/Magento/Deploy/Service/DeployPackage.php index 3ec9e3432f9d7..809680df9714c 100644 --- a/app/code/Magento/Deploy/Service/DeployPackage.php +++ b/app/code/Magento/Deploy/Service/DeployPackage.php @@ -8,6 +8,7 @@ use Magento\Deploy\Package\Package; use Magento\Deploy\Package\PackageFile; use Magento\Framework\App\State as AppState; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Locale\ResolverInterface as LocaleResolver; use Magento\Framework\View\Asset\ContentProcessorException; use Magento\Deploy\Console\InputValidator; @@ -138,7 +139,7 @@ public function deployEmulated(Package $package, array $options, $skipLogging = $this->errorsCount++; $this->logger->critical($errorMessage); $package->deleteFile($file->getFileId()); - throw new \Exception($errorMessage); + throw new LocalizedException($errorMessage); } catch (\Exception $exception) { $this->logger->critical( 'Compilation from source ' . $file->getSourcePath() . ' failed' . PHP_EOL . (string)$exception