/**
  * Set as the default error handler by CakePHP.
  *
  * Use 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|null $file File on which error occurred
  * @param int|null $line Line that triggered the error
  * @param array|null $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 = ['level' => $log, 'code' => $code, 'error' => $error, 'description' => $description, 'file' => $file, 'line' => $line];
     $debug = Configuration::getInstance()->get('debug');
     if ($debug) {
         $data += ['context' => $context, 'start' => 3, 'path' => Debugger::trimPath($file)];
     }
     $this->_displayError($data, $debug);
     $this->_logError($log, $data);
     return true;
 }