Disable fancy errors in CakePHP

Posted on 21 July 2009 (04:35 PM)

Here at work we often go crazy because of CakePHP's "helpful" displaying of error messages.

They are littered with HTML and, even worse, Javascript and provide an often superfluous stack trace, which makes it harder to read the actual error message.

If you just want readable, plain text error messages in your projects, add the following to /app/config/bootstrap.PHP:

  1. function displayErrorWithoutCrap() {
  2. // returning false here means the internal PHP error handler will take over again and display a neat, clean error
  3. return false;
  4. }
  5. set_error_handler('displayErrorWithoutCrap');
  6. Download this code: /code/disable_fancy_errors_in_cakephp1.txt

And if the Cake guys could make this configurable in their next release, that would just be awesome.

Back to top

Filed under PHP, CakePHP

Comments:

No comments have been added yet, you could be the first!

Leave a comment

RE: Disable fancy errors in CakePHP

Note to spammers: rel="nofollow" will be added to links. If I consider your comment spam, your IP-address might get blocked.

HTML not allowed. URLS will be auto-linked. Maximum length is 1250 characters.

I understand this is inconvenient, but the spam I'm receiving on this website is driving me nuts. Please forgive me and cope with it until I find a better solution.

Mandatory fields are marked by an asterisk (*).

Increase textarea-size Decrease textarea-size

Back to top

Preferences

These settings will be saved for your convenience.