From ef525e5bb595bce6bcd5af1efb023af9c450761c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=81nis=20Elmeris?= Date: Thu, 21 Dec 2017 15:38:27 +0200 Subject: [PATCH 1/5] Display a more meaningful error message in case of misspelt module name. [LogicException] Component 'VendorA_ModuleB' of type '' is not correctly registered. instead of [Magento\Framework\Exception\FileSystemException] The file "/composer.json" doesn't exist --- lib/internal/Magento/Framework/Module/Dir.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/internal/Magento/Framework/Module/Dir.php b/lib/internal/Magento/Framework/Module/Dir.php index 936fce3a046b7..ecd24c5db767a 100644 --- a/lib/internal/Magento/Framework/Module/Dir.php +++ b/lib/internal/Magento/Framework/Module/Dir.php @@ -45,6 +45,10 @@ public function getDir($moduleName, $type = '') { $path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName); + if (! isset($path)) { + throw new \LogicException("Component '$moduleName' of type '$type' is not correctly registered."); + } + if ($type) { if (!in_array($type, [ self::MODULE_ETC_DIR, From ae3cbb952db13e4d82f6b089fc4a7cf03bb356d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=81nis=20Elmeris?= Date: Fri, 22 Dec 2017 22:04:12 +0200 Subject: [PATCH 2/5] Do not throw \LogicException, as it would break backwards-compatibility. --- lib/internal/Magento/Framework/Module/Dir.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Module/Dir.php b/lib/internal/Magento/Framework/Module/Dir.php index ecd24c5db767a..47e0836db7f33 100644 --- a/lib/internal/Magento/Framework/Module/Dir.php +++ b/lib/internal/Magento/Framework/Module/Dir.php @@ -45,8 +45,9 @@ public function getDir($moduleName, $type = '') { $path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName); - if (! isset($path)) { - throw new \LogicException("Component '$moduleName' of type '$type' is not correctly registered."); + if (!isset($path)) { + // (Do not throw \LogicException, as it would break backwards-compatibility.) + throw new \InvalidArgumentException("Component '$moduleName' of type '$type' is not correctly registered."); } if ($type) { From 36268c648e6a8750a7ca4b231260de4da4d569b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=81nis=20Elmeris?= Date: Fri, 22 Dec 2017 23:18:20 +0200 Subject: [PATCH 3/5] Allow directory to be not set for non-module types. --- lib/internal/Magento/Framework/Module/Dir.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Module/Dir.php b/lib/internal/Magento/Framework/Module/Dir.php index 47e0836db7f33..309fa33778de4 100644 --- a/lib/internal/Magento/Framework/Module/Dir.php +++ b/lib/internal/Magento/Framework/Module/Dir.php @@ -45,8 +45,9 @@ public function getDir($moduleName, $type = '') { $path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName); - if (!isset($path)) { - // (Do not throw \LogicException, as it would break backwards-compatibility.) + // An empty $type means it's gettind the directory of the module itself. + if (empty($type) && !isset($path)) { + // Note: do not throw \LogicException, as it would break backwards-compatibility. throw new \InvalidArgumentException("Component '$moduleName' of type '$type' is not correctly registered."); } From 196f6913bb4dd419edaa6b355335d88f9b55f316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=81nis=20Elmeris?= Date: Fri, 22 Dec 2017 23:21:34 +0200 Subject: [PATCH 4/5] Fix misspelling. --- lib/internal/Magento/Framework/Module/Dir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Module/Dir.php b/lib/internal/Magento/Framework/Module/Dir.php index 309fa33778de4..8ce818961cdf8 100644 --- a/lib/internal/Magento/Framework/Module/Dir.php +++ b/lib/internal/Magento/Framework/Module/Dir.php @@ -45,7 +45,7 @@ public function getDir($moduleName, $type = '') { $path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName); - // An empty $type means it's gettind the directory of the module itself. + // An empty $type means it's getting the directory of the module itself. if (empty($type) && !isset($path)) { // Note: do not throw \LogicException, as it would break backwards-compatibility. throw new \InvalidArgumentException("Component '$moduleName' of type '$type' is not correctly registered."); From 9c5975d0de2e81806d3c3c6cb35e0e27d8934611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=81nis=20Elmeris?= Date: Fri, 22 Dec 2017 23:37:43 +0200 Subject: [PATCH 5/5] Simpler message, as this appears only for the modules themselves. --- lib/internal/Magento/Framework/Module/Dir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Module/Dir.php b/lib/internal/Magento/Framework/Module/Dir.php index 8ce818961cdf8..688c7c43ac0e4 100644 --- a/lib/internal/Magento/Framework/Module/Dir.php +++ b/lib/internal/Magento/Framework/Module/Dir.php @@ -48,7 +48,7 @@ public function getDir($moduleName, $type = '') // An empty $type means it's getting the directory of the module itself. if (empty($type) && !isset($path)) { // Note: do not throw \LogicException, as it would break backwards-compatibility. - throw new \InvalidArgumentException("Component '$moduleName' of type '$type' is not correctly registered."); + throw new \InvalidArgumentException("Module '$moduleName' is not correctly registered."); } if ($type) {