I think that is a very good solution.
I don't know if another debug level  is necessary since you resolve it
in a good way.

On Mar 5, 8:35 am, Aidan Lister <[email protected]> wrote:
> My previous comment was incorrect, you can easily override
> ErrorHandler methods by creating app_error.php and AppError extends
> ErrorHandler (as per my first comment).
>
> This is how I have decided to handle production errors now:
>
> <?php
> /**
>  * Handle logging errors in production mode
>  */
> if (Configure::read() === 0) {
>
>     // Disable the default handling and include logger
>     define('DISABLE_DEFAULT_ERROR_HANDLING', 1);
>     uses('cake_log');
>
>     /**
>      * A function to directly log errors
>      *
>      * @param $errno The error number
>      * @param $errstr The error description
>      * @param $errfile The file where the error occured
>      * @param $errline The line of the file where the error occured
>      * @return bool Success
>      */
>     function productionError($errno, $errstr, $errfile, $errline) {
>         if ($errno === 2048) {
>             return;
>         }
>
>                 $level = LOG_DEBUG;
>                 switch ($errno) {
>                         case E_PARSE:
>                         case E_ERROR:
>                         case E_CORE_ERROR:
>                         case E_COMPILE_ERROR:
>                         case E_USER_ERROR:
>                                 $error = 'Fatal Error';
>                                 $level = LOG_ERROR;
>                         break;
>                         case E_WARNING:
>                         case E_USER_WARNING:
>                         case E_COMPILE_WARNING:
>                         case E_RECOVERABLE_ERROR:
>                                 $error = 'Warning';
>                                 $level = LOG_WARNING;
>                         break;
>                         case E_NOTICE:
>                         case E_USER_NOTICE:
>                                 $error = 'Notice';
>                                 $level = LOG_NOTICE;
>                         break;
>                         default:
>                                 return false;
>                         break;
>                 }
>
>                 CakeLog::write($level, "{$error} ({$errno}): {$errstr} in
> [{$errfile}, line {$errline}]");
>
>                 if ($error == 'Fatal Error') {
>                         die();
>                 }
>                 return true;
>     }
>
>     // Use the above handling
>     set_error_handler('productionError');
>
> }
>
> This code belongs in your bootstrap.php file.
>
> This is how I am handling custom error pages in production:
> <?php
>     function __construct($method, $messages)
>     {
>         $methods = array('paypal', 'system', 'payflow', 'cart',
> 'generate');
>         if (in_array($method, $methods)) {
>             Configure::write('debug', 1);
>         }
>         parent::__construct($method, $messages);
>     }
> ?>
>
> Ideally cake would support a debug level of between production and
> development, this would allow:
> - Errors to still be logged in production environments
> - Custom error handlers (as raised by cakeError) to be displayed to
> the user.
>
> I have raised an enhancement so the clever folks in the development
> team can consider:https://trac.cakephp.org/ticket/6165
>
> Regards,
> Aidan
>
> On Mar 4, 9:02 pm, Aidan Lister <[email protected]> wrote:
>
> > Hi,
>
> > Firstly, there is no mechanism to overriding any of the functions in
> > the ErrorHandler class.
>
> > Secondly, it's completely unnecessary, as you can use either
> > _outputMessage() or appError() to achieve the same thing. Neither of
> > these lend themselves to a) or b).
>
> > - Aidan
>
> > On Mar 4, 5:28 am, mscdex <[email protected]> wrote:
>
> > > On Mar 3, 1:08 pm, Aidan Lister <[email protected]> wrote:
>
> > > > Does anyone else have any suggestions?
>
> > > Why not override ErrorHandler's default 'error' function to handle the
> > > HTTP errors?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to