Skip to content

Commit fad0927

Browse files
authored
Improved text of exception message
When some third-party module has syntax error inside its composer.json, it's very hard to determine which module caused an exception. This PR changes default message with the following: ``` Some_Module's composer.json error: Decoding failed: Syntax error ```
1 parent 5640494 commit fad0927

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/internal/Magento/Framework/Module/PackageInfo.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,15 @@ private function load()
8282
foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleName => $moduleDir) {
8383
$key = $moduleDir . '/composer.json';
8484
if (isset($jsonData[$key]) && $jsonData[$key]) {
85-
$packageData = \Zend_Json::decode($jsonData[$key]);
85+
try {
86+
$packageData = \Zend_Json::decode($jsonData[$key]);
87+
} catch (\Zend_Json_Exception $e) {
88+
throw new \Zend_Json_Exception(
89+
sprintf("%s's composer.json error: ", $moduleName) .
90+
$e->getMessage()
91+
);
92+
}
93+
8694
if (isset($packageData['name'])) {
8795
$this->packageModuleMap[$packageData['name']] = $moduleName;
8896
}

0 commit comments

Comments
 (0)