Sunday, May 20, 2012

Re: No error logging by default



On Saturday, 19 May 2012 12:43:21 UTC+2, John Sutton wrote:
Hi there

I read in Config/core.php:

/**
 * Configure the Error handler used to handle errors for your application.  By default
 * ErrorHandler::handleError() is used.  It will display errors using Debugger, when debug > 0
 * and log errors with CakeLog when debug = 0.

In both 2.0 and 2.1 I've done the following.  Created a very simple database schema (1 table called users with an id field and a name field) and then done:

cake bake project myapp
(fix up Config/database.php)
cake bake all User

I then have a working CRUD application.

Then in one of the controller actions in Controller/UsersController.php I introduce a spurious function call:

    public function view($id = null) {
        $this->User->id = $id;
        if (!$this->User->exists()) {
            throw new NotFoundException(__('Invalid user'));
        }
        nosuchfunc();
        $this->set('user', $this->User->read(null, $id));
    }

Now when I attempt to view a record of course I get a page back:

Fatal error: Call to undefined function nosuchfunc() in /var/www/myapp/Controller/UsersController.php on line 32

Fatal errors shouldn't occur in production at all, and will be in your webserver error log.

I think it wasn't until 2.2 that the fatal error handler was added (feel free to check for that on github) - I.e. with that version or later you'll find such an error is handled gracefully and logged (unless you manage to trigger another fatal error in the process of displaying a fatal error).

AD

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate