コード例 #1
0
 /**
  * Set as the default error handler by CakePHP.
  *
  * Use App/Config/error.php to customize or replace this error handler.
  * This function will use Debugger to display errors when debug > 0. And
  * will log errors to Log, when debug == 0.
  *
  * You can use the 'errorLevel' option to set what type of errors will be handled.
  * Stack traces for errors can be enabled with the 'trace' option.
  *
  * @param int $code Code of error
  * @param string $description Error description
  * @param string $file File on which error occurred
  * @param int $line Line that triggered the error
  * @param array $context Context
  * @return bool true if error was handled
  */
 public function handleError($code, $description, $file = null, $line = null, $context = null)
 {
     if (error_reporting() === 0) {
         return false;
     }
     list($error, $log) = $this->mapErrorCode($code);
     if ($log === LOG_ERR) {
         return $this->handleFatalError($code, $description, $file, $line);
     }
     $data = array('level' => $log, 'code' => $code, 'error' => $error, 'description' => $description, 'file' => $file, 'line' => $line);
     $debug = Configure::read('debug');
     if ($debug) {
         $data += ['context' => $context, 'start' => 3, 'path' => Debugger::trimPath($file)];
     }
     $this->_displayError($data, $debug);
     $this->_logError($log, $data);
     return true;
 }
コード例 #2
0
 /**
  * testTrimPath method
  *
  * @return void
  */
 public function testTrimPath()
 {
     $this->assertEquals('APP/', Debugger::trimPath(APP));
     $this->assertEquals('CORE' . DS . 'src' . DS, Debugger::trimPath(CAKE));
     $this->assertEquals('Some/Other/Path', Debugger::trimPath('Some/Other/Path'));
 }