Custom Error Handling in CakePHP when debug = 0

Not sure if this is the most correct way to handle this, but I wanted to use a custom error method in my controllers. However, if you’ve been working with CakePHP a bit, you’ll notice that Cake automatically throws a 404 error when you set debug to 0.

To get around this I opened up /cake/libs/error.php and commented out the following lines:

/*if (Configure::read() == 0) {
$method = 'error404';
if (isset($code) && $code == 500) {
$method = 'error500';
}
}*/

This seems to solve the problem, for now. Hopefully this will be fixed in a future version of Cake because I detest modifying core files.

Advertisements
Next Post
Leave a comment

1 Comment

  1. Cake has an error handling class, you can extend it by creating app_error.php where app controller is on over write the methods you want in that.

    never good to hack the core

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: