예제 #1
0
 public function _displayException($exception)
 {
     if ($exception instanceof MissingControllerException) {
         // Here handle MissingControllerException by yourself
     } else {
         parent::_displayException($exception);
     }
 }
 /**
  * Intercept exception handling to send a mail before continuing with the default logic
  * @see \Cake\Error\BaseErrorHandler::handleException()
  */
 public function handleException(Exception $exception)
 {
     // send a debug mail with the fatal exception
     if ($this->email && !in_array(get_class($exception), $this->_skipExceptions)) {
         $this->email->debug('Application exception', Misc::dump($exception, $exception->getMessage(), true));
     }
     // continue with exception handle logic
     parent::handleException($exception);
 }
예제 #3
0
 /**
  * Displays an exception response body.
  *
  * @param \Exception $exception The exception to display
  *
  * @return void
  */
 protected function _displayException($exception)
 {
     if (Configure::read('debug')) {
         $whoops = $this->getWhoopsInstance();
         $whoops->pushHandler(new PrettyPageHandler());
         $whoops->handleException($exception);
     } else {
         parent::_displayException($exception);
     }
 }
예제 #4
0
 /**
  * Handles exception logging
  *
  * @param \Exception $exception Exception instance.
  * @return bool
  */
 protected function _logException(Exception $exception)
 {
     $blacklist = ['Cake\\Routing\\Exception\\MissingControllerException', 'Cake\\Routing\\Exception\\MissingActionException', 'Cake\\Routing\\Exception\\PrivateActionException', 'Cake\\Routing\\Exception\\NotFoundException', 'Cake\\Datasource\\Exception\\RecordNotFoundException', 'Cake\\Network\\Exception\\MethodNotAllowedException', 'Cake\\Network\\Exception\\BadRequestException', 'Cake\\Network\\Exception\\ForbiddenException', 'Cake\\Network\\Exception\\GoneException', 'Cake\\Network\\Exception\\ConflictException', 'Cake\\Network\\Exception\\InvalidCsrfToken', 'Cake\\Network\\Exception\\UnauthorizedException', 'Cake\\Network\\Exception\\NotAcceptableException'];
     if (isset($this->_options['log404'])) {
         $blacklist = $this->_options['log404'];
     }
     if ($blacklist && in_array(get_class($exception), (array) $blacklist)) {
         $level = LOG_ERR;
         Log::write($level, $this->_getMessage($exception), ['404']);
         return false;
     }
     return parent::_logException($exception);
 }
예제 #5
0
 /**
  * Handles exception logging
  *
  * @param \Exception $exception Exception instance.
  * @return bool
  */
 protected function _logException(\Exception $exception)
 {
     $blacklist = ['Cake\\Routing\\Exception\\MissingControllerException', 'Cake\\Routing\\Exception\\MissingActionException', 'Cake\\Routing\\Exception\\PrivateActionException', 'Cake\\Routing\\Exception\\NotFoundException'];
     if (isset($this->_options['log404'])) {
         $blacklist = $this->_options['log404'];
     }
     if ($blacklist && in_array(get_class($exception), (array) $blacklist)) {
         $level = LOG_ERR;
         Log::write($level, $this->_getMessage($exception), ['404']);
         return;
     }
     return parent::_logException($exception);
 }
예제 #6
0
 /**
  * Test that errors going into Cake Log include traces.
  *
  * @return void
  */
 public function testHandleErrorLoggingTrace()
 {
     Configure::write('debug', false);
     $errorHandler = new ErrorHandler(['trace' => true]);
     $errorHandler->register();
     $this->_restoreError = true;
     $this->_logger->expects($this->once())->method('log')->with($this->matchesRegularExpression('(notice|debug)'), $this->logicalAnd($this->stringContains('Notice (8): Undefined variable: out in '), $this->stringContains('Trace:'), $this->stringContains(__NAMESPACE__ . '\\ErrorHandlerTest::testHandleErrorLoggingTrace()')));
     $out = $out + 1;
 }
 /**
  * Handle uncaught exceptions.
  *
  * @param \Exception $exception Exception instance.
  * @return void
  * @throws \Exception When renderer class not found
  * @see http://php.net/manual/en/function.set-exception-handler.php
  */
 public function handleException(Exception $exception)
 {
     $this->handle($exception);
     return parent::handleException($exception);
 }
예제 #8
0
 /**
  * Handle uncaught exceptions.
  *
  * @param \Exception $exception Exception instance.
  * @return void
  * @throws \Exception When renderer class not found
  * @see http://php.net/manual/en/function.set-exception-handler.php
  */
 public function handleException(Exception $exception)
 {
     $sentryHandler = new SentryHandler();
     $sentryHandler->handle($exception);
     return parent::handleException($exception);
 }
예제 #9
0
 /**
  * test handleFatalError generating log.
  *
  * @return void
  */
 public function testHandleFatalErrorLog()
 {
     $this->_logger->expects($this->at(0))->method('write')->with('error', $this->logicalAnd($this->stringContains(__FILE__ . ', line ' . (__LINE__ + 10)), $this->stringContains('Fatal Error (1)'), $this->stringContains('Something wrong')));
     $this->_logger->expects($this->at(1))->method('write')->with('error', $this->stringContains('[Cake\\Error\\FatalErrorException] Something wrong'));
     $errorHandler = new ErrorHandler(['log' => true]);
     ob_start();
     $errorHandler->handleFatalError(E_ERROR, 'Something wrong', __FILE__, __LINE__);
     ob_clean();
 }
예제 #10
0
 /**
  * Encount fatal error handler
  *
  * @access public
  * @author sakuragawa
  */
 public function handleFatalError($code, $description, $file, $line)
 {
     $this->execute($code, 'FatalError', $description, $file, $line);
     return parent::handleFatalError($code, $description, $file, $line);
 }
예제 #11
0
 public function _displayException($exception)
 {
     parent::_displayException($exception);
 }