Conversation
This ensures settings done in AppController are used when generating error responses too.
That will be a problem for most people. Extending AppController but skipping initialization is going to trip up people, because most apps perform logic in the I don't think this is a good practice, because the odds of a cascading failure to render the error page is more likely. The moment someone has an error in a component or the AppController the error rendering will fail. What I recommend, is to add something to the Error controller in the core. That will introduce a warning if the developer uses custom error views. The warning would state
|
This is exactly the reason that the core ErrorController doesn't extend |
Good point, I can add an empty
.
Yeah there is the potential for cascading failures but exception renderer can mitigate that. There are checks to use
Then users would just create an "empty" Adding an |
|
If we add an empty |
The two common issues I have seen people have with error pages are:
I am hoping most do these settings in If they are doing view/response related setting in Like I said above adding this |
|
Inheritance might be backwards. Instead of With, the ErrorController living in the app namespace. This way, the minimum requirements for a theme is placed in the This would remove the need to overload methods just to silence AppController, and removes the risk that you missed something in |
What about Inheriting from ErrorController sounds strange. Maybe ErrorHandlerController. |
|
@ADmad I'm not against trying out this approach. We can always change our minds later if this proves to be as problematic or more later. |
Since we are also skipping AppController's initialize() we need to ensure it's beforeFilter() is also not run.
Looking at the PR now I really like it. To stop accidental behaviour, maybe |
|
I like this change too. It would allow users to add custom HTTP status codes in their own ErrorController. As a result, I can solve cakephp/cakephp#8962 by using my original approach. |
Ref: cakephp/app#432 (comment) Signed-off-by: Rick Guyer <ricoguyer@gmail.com>
This ensures settings done in AppController are used when generating error responses too.
I have seen numerous users on IRC/Slack struggle to figure out why the setting they have done in
AppControllerdon't affect their error pages since they don't realize that by default the core'sErrorControlleris used which extendsControllernotAppController. Most go down the wrong path of either trying to use custom error handler or exception renderer. So perhaps the docs need improving too. Regardless having aErrorControllerin app itself should save newbies some hair pulling.