-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DX] Misleading error when the namespace of a controller is wrong #14073
Comments
why does AppBundle/Controller try to load routing_dev.yml again when the namespace is wrong ? this does not make any sense |
@stof I know it's very strange. By the way, yesterday I was contacted by a Symfony developer which suffered the exact same problem and for the same reasons (moving a controller without updating its namespace). |
Possibly a problem with re-throwing exceptions in FileLoader My steps to reproduce are:
I was unable to reproduce the problem following the steps above for Symfony 2.6.4 |
I've found this commit 0ebcf63 to have generated the problem. |
Does #14192 enhance the situation? As stated in 0ebcf63#commitcomment-10558553, the issue is not in this commit, but in the error handling strategy of the route loader. A circular exception is just plain wrong. |
@nicolas-grekas it's better ... but it's not good enough yet :) After applying your changes, I see 4 exceptions now. However, I see first the "wrong exceptions". The best exception in this case would be the number 2 (and possibly the number 1 too): |
So, HttpKernel is at the maximum that is legitimate to do: error reporting does not hide anything so the situation can be handled by reading the page. |
#14192 does the trick and saves a lot of debugging. Thx nicholas. |
@nicolas-grekas the first exception in this case is wrong: the exception happened too early in the Symfony lifecycle to even give a chance to the kernel to throw the kernel.exception event |
…to bounced exceptions (nicolas-grekas) This PR was merged into the 2.7 branch. Discussion ---------- [HttpKernel] Embed the original exception as previous to bounced exceptions | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14073 | License | MIT | Doc PR | - Commits ------- bb020f4 [HttpKernel] Embed the original exception as previous to bounced exceptions
…ounced exceptions (nicolas-grekas) This PR was merged into the 2.3 branch. Discussion ---------- [HttpKernel] Embed the original exception as previous to bounced exceptions | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14073 | License | MIT | Doc PR | - Commits ------- [HttpKernel] Embed the original exception as previous to bounced exceptions
The problem
The other day I was playing with the Symfony Demo application, in which the routing is simply defined as:
I had a
BlogController.php
file with@Route()
annotations insrc/AppBundle/Controller/BlogController.php
file.Then, I moved this controller to the
src/AppBundle/Controller/Admin/
folder without updating the namespace of the PHP class. Then, the application displayed the following error message:Sadly this error message is very misleading because
CircularReferenceException
message looks scary and the error keeps talking about therouting_dev.yml
file, which has nothing to do with the actual error.The solution
Symfony already includes some great error messages when you are warned about typos and PHP classes mislocations. I'd like to see a better error message when the namespace of a controller file is not correct.
The text was updated successfully, but these errors were encountered: