Writes an error to a logfile.

@param	string	$errstr	The error which occured recently
@param	array	$backtrace	The backtrace array created via debug_backtrace()
@param	string	$errortype	The errortype that occured
552364
protected function _errorhandler_file($errstr, $backtrace, $errortype) {
		$body  = '############################## '.$errortype."\n";
		$body .= 'Datum:      '.date("d.m.Y - H:i:s")."\n";
		
		if (isset($_SERVER['REQUEST_URI'])) {
			$body .= 'URL:        '.$_SERVER['REQUEST_URI']."\n";
			$body .= 'IP:         '.$_SERVER['REMOTE_ADDR']."\n";
			$body .= 'User-Agent: '.(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '-') ."\n";
		} else {
			$body .= 'CLI:        '.(implode(' ', $_SERVER['argv']))."\n";
		}

		$body .= 'Meldung:    '.$errstr."\n";
		$body .= 'Backtrace:  '."\n\n";

		foreach ($backtrace as $value) {
			$body .= '       File: '.$value['file']." (Line ".$value['line'].")\n";
			$body .= '   Function: '.$value['class'].$value['type'].$value['function'].'()'."\n\n";
		}
		$body .= "\n";

		file_put_contents($this->_logfile, $body, FILE_APPEND);
	}
274226
public function phpErrorHandler($errno, $errstr, $errfile, $errline) {
		foreach($this->ignoreDirs as $dir) {
			if(strpos($errfile, $dir) === 0)
				return;
		}

		if($this->isLogging() && $this->logPHPErrors)
			$this->log(\Psr\Log\LogLevel::NOTICE, 'PHP ('.static::getPHPError($errno).'): '.$errstr, $errfile, $errline);
		throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
	}
324672
public static function errorHandler($errno, $errstr, $errfile = null, $errline = null, array $errcontext = array())
    {
//echo __METHOD__;
        if (!(error_reporting() & $errno)) {
            return;
        }
        self::exceptionHandler(
            new Error($errstr, Response::STATUS_ERROR, $errfile, $errline)
        );
    }
995399
public function handleError($errno, $errstr, $errfile, $errline) {
    $errorIsEnabled = (bool)($errno & ini_get('error_reporting'));

    // FATAL ERROR
    if(isset(self::$fatalErrors[$errno]) && $errorIsEnabled) {
      throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
    }

    // NON-FATAL ERROR/WARNING/NOTICE
    else if($errorIsEnabled) {
      $info = $errstr." in ".$errfile." on line ".$errline;
      self::$logger->logByErrorType($errno, $info);
    }
  }
1220949
function onErrorHandle($errno, $errstr, $errfile, $errline)
    {
        $error = array(
            'message' => $errstr,
            'file' => $errfile,
            'line' => $errline,
        );
        $this->errorResponse($error);
    }
394266
public function warningHandler($errno, $errstr, $errfile, $errline) {
		if ($errno != E_WARNING && $errno != E_USER_WARNING) {
			return false;
		}
		
		$message = "WARNING! [$errno] $errstr. Line $errline in file $errfile. ";
		
		// because some more problems can happen during logging or display
		// better to disable this handler
		$this->setCatchWarnings(false);
		
		$exception = new \Exception($message);

		$this->processError($exception,'warning');		
		
		$this->setCatchWarnings(true);
	}
596154
function error($msg, $section = 'bors', $trace = false, $extra = array())
	{
		static $entered = false;
		if($entered)
			throw new Exception('Reentered logger with '.$msg.' in section '.$section);

		$entered = true;

		try
		{
			$this->logger($section, Logger::ERROR, $trace)->addError($msg, $extra);
		}
		catch(Exception $e)
		{
			echo "Exception while error logging:\n<code><xmp>".$e->getMessage()."</xmp></code>\nFirst error is:\n<xmp>$msg\nin".bors_debug::trace()."</xmp>";
		}

		$entered = false;
	}
1040349
public function generateErrorWrapper($errno, $errstr, $errfile, $errline)
    {
        return new ErrorWrapper(
            $errno,
            $errstr,
            $errfile,
            $errline,
            $this->buildErrorTrace($errfile, $errline),
            $this->utilities
        );
    }
458906
public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
    {
        // Don't throw exception if error reporting is switched off
        if (error_reporting() == 0) {
            return;
        }
        // Only throw exceptions for errors we are asking for
        if (error_reporting() & $errno) {

            $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline);
            if ($this->throwErrorExceptions) {
                throw $exception;
            } else {
                $this->fb($exception);
            }
        }
    }
663278
final protected function _log($type, array $args)
	{
		// nothing passed in, don't do anything
		if (count($args) === 0 && $type !== self::GROUP_END) {
			return;
		}
		$this->_processed = array();

		$logs = array_map([$this, '_convert'], $args);
		$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4);
		$backtrace_message = 'unknown';
		$backtrace = end($backtrace);
		if (isset($backtrace['file'], $backtrace['line'])) {
			$backtrace_message = $this->_formatLocation(
				$backtrace['file'],
				$backtrace['line']
			);
		}
		$this->_addRow($logs, $backtrace_message, $type);
	}
576276
function errorHandler( $errno, $errstr, $errfile, $errline )
    {
        if ( error_reporting() == 0 ) // @ error-control operator is used
            return;
        if ( !eZDebug::isDebugEnabled() )
            return;
        $str = "$errstr in $errfile on line $errline";
        if ( empty( $GLOBALS['eZDebugPHPErrorNames'] ) )
        {
            $GLOBALS['eZDebugPHPErrorNames'] =
                array( E_ERROR => 'E_ERROR',
                       E_PARSE => 'E_PARSE',
                       E_CORE_ERROR => 'E_CORE_ERROR',
                       E_COMPILE_ERROR => 'E_COMPILE_ERROR',
                       E_USER_ERROR => 'E_USER_ERROR',
                       E_WARNING => 'E_WARNING',
                       E_CORE_WARNING => 'E_CORE_WARNING',
                       E_COMPILE_WARNING => 'E_COMPILE_WARNING',
                       E_USER_WARNING => 'E_USER_WARNING',
                       E_NOTICE => 'E_NOTICE',
                       E_USER_NOTICE => 'E_USER_NOTICE',
                       E_STRICT => 'E_STRICT' );
            // Since PHP 5.2
            if ( defined('E_RECOVERABLE_ERROR') )
                $GLOBALS['eZDebugPHPErrorNames'][E_RECOVERABLE_ERROR] = 'E_RECOVERABLE_ERROR';
            // Since PHP 5.3
            if ( defined('E_DEPRECATED') )
                $GLOBALS['eZDebugPHPErrorNames'][E_DEPRECATED] = 'E_DEPRECATED';
            if ( defined('E_USER_DEPRECATED') )
                $GLOBALS['eZDebugPHPErrorNames'][E_USER_DEPRECATED] = 'E_USER_DEPRECATED';

        }
        $errname = "Unknown error code ($errno)";
        if ( isset( $GLOBALS['eZDebugPHPErrorNames'][$errno] ) )
        {
            $errname = $GLOBALS['eZDebugPHPErrorNames'][$errno];
        }
        switch ( $errname )
        {
            case 'E_ERROR':
            case 'E_PARSE':
            case 'E_CORE_ERROR':
            case 'E_COMPILE_ERROR':
            case 'E_USER_ERROR':
            case 'E_RECOVERABLE_ERROR':
            {
                $this->writeError( $str, 'PHP: ' . $errname );
            } break;

            case 'E_WARNING':
            case 'E_CORE_WARNING':
            case 'E_COMPILE_WARNING':
            case 'E_USER_WARNING':
            case 'E_DEPRECATED':
            case 'E_USER_DEPRECATED':
            {
                $this->writeWarning( $str, 'PHP: ' . $errname );
            } break;

            case 'E_NOTICE':
            case 'E_USER_NOTICE':
            {
                $this->writeNotice( $str, 'PHP: ' . $errname );
            } break;

            case 'E_STRICT':
            {
                return $this->writeStrict( $str, 'PHP: ' . $errname );
            } break;
            default:
            {
                 $this->writeError( $str, 'PHP: ' . $errname );
            } break;
        }
    }
405936
public function errorHandler($errno, $errstr, $errfile, $errline)
    {
        // Honour error suppression through @
        if (($errorReporting = error_reporting()) === 0) {
            return true;
        }
        
        $logType = null;

        foreach ($this->errorLogGroups as $candidateLogType => $errorTypes) {
            if (in_array($errno, $errorTypes)) {
                $logType = $candidateLogType;
                break;
            }
        }
        
        if (is_null($logType)) {
            throw new \Exception(sprintf(
                "No log type found for errno '%s'",
                $errno
            ));
        }

        $exception = $this->createException($errstr, $errno, $errfile, $errline);
        
        // Log all errors regardless of type
        $context = array(
            'file' => $errfile,
            'line' => $errline
        );
    
        if ($this->reportBacktrace) {
            $context['backtrace'] = $this->getBacktraceReporter()->getBacktrace();
        }

        if ($this->exceptionInContext) {
            $context['exception'] = $exception;
        }
    
        $this->logger->$logType($errstr, $context);
    
        // Check the error_reporting level in comparison with the $errno (honouring the environment)
        // And check that $showErrors is on or the site is live
        if (($errno & $errorReporting) === $errno &&
            ($this->showErrors || $this->getEnvReporter()->isLive())) {
            $this->getErrorReporter()->reportError($exception);
        }
            
        if (in_array($errno, $this->terminatingErrors)) {
            $this->terminate();
        }
        
        // ignore the usually handling of this type of error
        return true;
    }
472625
protected function throwError($errno, $errstr, $errfile, $errline)
        {
            $msg = "";

            switch ($errno) {
                case E_USER_ERROR:
                case E_USER_WARNING:
                    $msg .= "<b>ERROR</b> [$errno] $errstr<br />\n";
                    $msg .= "  Fatal error on line $errline in file $errfile";
                    $msg .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
                    $msg .= "Aborting...<br />\n";

                    throw new Exception($msg);
                    //exit(1);
                break;

                case E_USER_NOTICE:
                default:
            }

            // Don't execute PHP internal error handler
            return true;
        }
90001
private function logError($errno, $errstr, $errfile, $errline)
    {
        if (!($errno & $this->loggedErrors)) {
            return false;
        }

        $loggedLevel = isset($this->logLevels[$errno]) ? $this->logLevels[$errno] : 'error';

        $stacktrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        $stacktrace = array_slice($stacktrace, 2);

        array_unshift($stacktrace, [
            'file' => $errfile,
            'line' => $errline,
        ]);

        $this->logger->log($loggedLevel, $errstr, [
            'errorCode' => $errno,
            'errorType' => self::getErrorType($errno),
            'errorFile' => $errfile,
            'errorLine' => $errline,
            'errorStacktrace' => $this->formatStacktrace($stacktrace),
        ]);

        return true;
    }
257544
function errHandler(err) {
    /* istanbul ignore else */
    if (_output) {
      err = err instanceof Error ? err : new Error(err)
      _emitter.emit('end', err)
      _output = null
    }
    else
      console.error('jspreproc: ' + err)
  }
29819
protected function output($errno, $errstr, $errfile, $errline, $errcontext)
    {
        $reporter = Debug::create_debug_view();

        // Coupling alert: This relies on knowledge of how the director gets its URL, it could be improved.
        $httpRequest = null;
        if (isset($_SERVER['REQUEST_URI'])) {
            $httpRequest = $_SERVER['REQUEST_URI'];
        }

        if (isset($_SERVER['REQUEST_METHOD'])) {
            $httpRequest = $_SERVER['REQUEST_METHOD'] . ' ' . $httpRequest;
        }

        $output = $reporter->renderHeader();
        $output .= $reporter->renderError($httpRequest, $errno, $errstr, $errfile, $errline);

        if (file_exists($errfile)) {
            $lines = file($errfile);

            // Make the array 1-based
            array_unshift($lines, "");
            unset($lines[0]);

            $offset = $errline-10;
            $lines = array_slice($lines, $offset, 16, true);
            $output .= $reporter->renderSourceFragment($lines, $errline);
        }
        $output .= $reporter->renderTrace($errcontext);
        $output .= $reporter->renderFooter();

        return $output;
    }
1180693
public function errorHandler($errno, $errstr, $errfile, $errline)
        {
            $errorMsg = $errstr . " (Line: " . $errline . ")";

            if ($errno != E_WARNING && $errno != E_NOTICE && $errno != E_STRICT) {
                throw new Exception($errorMsg, $errno);
            } else {
                return false; // Let PHP handle it
            }
        }