public function handleException(Exception $exception, $shutdown = false)
 {
     $this->_exception = $exception;
     $email = new CakeEmail('error');
     $prefix = Configure::read('ExceptionNotifier.prefix');
     $from = $email->from();
     if (empty($from)) {
         $email->from('*****@*****.**', 'Exception Notifier');
     }
     $subject = $email->subject();
     if (empty($subject)) {
         $email->subject($prefix . '[' . date('Ymd H:i:s') . '][' . $this->_getSeverityAsString() . '][' . ExceptionText::getUrl() . '] ' . $exception->getMessage());
     }
     if ($this->useSmtp) {
         $email->transport('Smtp');
         $email->config($this->smtpParams);
     }
     $text = ExceptionText::getText($exception->getMessage(), $exception->getFile(), $exception->getLine());
     $email->send($text);
     // return Exception.handler
     if ($shutdown || !$this->_exception instanceof ErrorException) {
         $config = Configure::read('Exception');
         $handler = $config['handler'];
         if (is_string($handler)) {
             call_user_func($handler, $exception);
         } elseif (is_array($handler)) {
             call_user_func_array($handler, $exception);
         }
     }
 }
 /**
  * handleException
  *
  * @param Exception $exception
  */
 public static function handleException(Exception $exception)
 {
     /**
      * @see ErrorHandler::handleException
      */
     $config = Configure::read('Exception');
     if (!empty($config['log'])) {
         $message = sprintf("[%s] %s\n%s", get_class($exception), $exception->getMessage(), $exception->getTraceAsString());
         CakeLog::write(LOG_ERR, $message);
     }
     $renderer = $config['renderer'];
     if ($renderer !== 'ExceptionRenderer') {
         list($plugin, $renderer) = pluginSplit($renderer, true);
         App::uses($renderer, $plugin . 'Error');
     }
     $force = Configure::read('ExceptionNotifier.force');
     $debug = Configure::read('debug');
     if (($force || $debug == 0) && self::_checkAllowed($exception)) {
         $prefix = Configure::read('ExceptionNotifier.prefix');
         $subject = $prefix . '[' . date('Ymd H:i:s') . '][Exception][' . ExceptionText::getUrl() . '] ' . $exception->getMessage();
         $body = ExceptionText::getBody($exception->getMessage(), $exception->getFile(), $exception->getLine());
         ExceptionMail::send($subject, $body);
     }
     /**
      * @see ErrorHandler::handleException
      */
     try {
         $error = new $renderer($exception);
         $error->render();
     } catch (Exception $e) {
         set_error_handler(Configure::read('Error.handler'));
         // Should be using configured ErrorHandler
         Configure::write('Error.trace', false);
         // trace is useless here since it's internal
         $message = sprintf("[%s] %s\n%s", get_class($e), $e->getMessage(), $e->getTraceAsString());
         trigger_error($message, E_USER_ERROR);
     }
 }