Fix Wrong Exception on Cli run when Command Not found #40063
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before Fix error on Cli run:
After :
Description (*)
If you have ever tried to run bin/magento and been greeted with the maddening: "There is no command found in the namespace"
you already know how opaque Magento (Adobe Commerce) can be when a single CLI command class is broken. One constructor typo, a missing dependency, or a bad module upgrade and—boom—the whole console goes dark. No stack-trace, no filename, no clue. You are left spelunking through logs or disabling modules by trial and error. More than 10 years Adobe is not able to fix this critical issue! I'm tired and submitted the PR.
What My PR tiny but vital quality-of-life improvement:
Catches the original exception thrown while Magento is assembling its command list.
Prints the real message and class name before the fallback “no command found” notice.
The change is only a few lines, but the impact is huge: you immediately see which command class failed and why, so you can fix the root cause in minutes instead of hours.
Why every extension author & integrator should care:
Faster CI/CD – Broken modules fail loudly during automated builds; no more silent time-outs.
Happier merchants – Support teams pinpoint faulty third-party code instead of asking store owners for full backups.
Lean core – The patch touches only CLI bootstrap code; zero risk to storefront performance.
Thanks for backing real-world developer experience improvements—your click today could save countless debugging hundreds hours tomorrow!
Related Issue