Example #1
0
 /**
  * Override the errorHandler
  */
 public static final function errorHandler($severity, $message, $filepath, $line)
 {
     $is_error = ((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR) & $severity) === $severity;
     $level = self::$levels[$severity];
     $context = self::getContext(self::ERROR, $level, $message, $filepath, $line);
     if (!in_array($severity, array_merge([E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR], self::$ignore), true)) {
         error_log("{$level}: {$message} in {$filepath} in line {$line}");
         if (!empty(self::$logger)) {
             self::$logger->error("{$level}: {$message} in {$filepath} in line {$line}", $context);
         }
     }
     if ($is_error) {
         if (!empty(self::$logger)) {
             self::$logger->critical("{$level}: {$message} in {$filepath} in line {$line}", $context);
         }
         if (!is_null(self::$lastAction)) {
             $fn = self::$lastAction;
             $fn();
         }
         self::$httpHandler->overwrite(self::getErrorTemplate(self::$httpHandler, self::$defaultErrorPath))->withStatus(500)->send();
     }
 }