Internal error handler

@internal Internal error handler
@param string $message Error message
@param string $file Filename
@param integer $line Line number
@param integer $code Error code
@return void
438134
private static function __triggerError($message, $file, $line, $code = 0)
        {
            if (self::$useExceptions) {
                throw new Exception($message, $file, $line, $code);
            } else {
                trigger_error($message, E_USER_WARNING);
            }
        }
932127
protected function _error($message, $code, $exception = null, $context = [])
    {
        if (isset($this->_errorHandler)) {
            call_user_func($this->_errorHandler, $message, $code, $exception, $context);
            trigger_error('FQDB error handler function should die() or throw another exception!', E_ERROR);
        } else {
            throw new FQDBException($message, $code, $exception);
        }
    }
442143
protected function _error($message, $code)
    {
        header("HTTP/1.0 {$code} {$message}");
        echo $message;

        TableRegistry::get('Field.FieldInstances')->connection()->disconnect();
        exit(0);
    }
185041
public function on_error( $num, $str, $file, $line, $context = NULL ) {

		$log_context = [];
		if ( $context ) {
			$skip_keys   = array_merge( array_keys( $GLOBALS ), self::$super_globals_keys );
			$skip        = array_fill_keys( $skip_keys, '' );
			$log_context = array_filter( array_diff_key( (array) $context, $skip ) );
		}

		$log_context[ 'file' ] = $file;
		$log_context[ 'line' ] = $line;

		// Log the PHP error.
		do_action(
			\Inpsyde\Wonolog\LOG,
			new Log( $str, self::$errors_level_map[ $num ], Channels::PHP_ERROR, $log_context )
		);

		return FALSE;
	}
634007
public function displayError($code, $message, $file, $line)
    {
        $data = array();
        $data['code'] = $code;
        $data['message'] = $message;
        $data['file'] = $file;
        $data['line'] = $line;
        $data['type'] = 'error';
        $data = $this->_formatError(debug_backtrace(), $data);
        $this->render('error', $data);

    }
245875
public function handle($code, $error, $file = null, $line = null) : void
    {
        $this->honeybadger->notify(
            new ErrorException($error, $code, 0, $file, $line)
        );

        call_user_func($this->previousHandler, $code, $error, $file, $line);
    }
818810
public function handler($number, $message, $file, $line, $context) {

		if(0 === error_reporting()) { 
			return;
		}

		$this -> error = new Error();
		$this -> error -> setFile($file); 
		$this -> error -> setMessage($message); 
		$this -> error -> setNumber($number); 
		$this -> error -> setLine($line); 
		$this -> error -> setDate(new DateTime()); 
		$this -> error -> setContext($context); 
		$this -> error -> setBacktrace(debug_backtrace(null, 5));
		$this -> error -> setIp(Request :: getIp());

		switch($this -> error -> getNumber()) {

			case E_ERROR :
			case E_CORE_ERROR :
			case E_COMPILE_ERROR :
			case E_PARSE :
				$this -> error -> setType('FATAL');
			break;
			
			case E_USER_ERROR :
			case E_RECOVERABLE_ERROR :
				$this -> error -> setType('ERROR');
			break;
		
			case E_WARNING :
			case E_CORE_WARNING :
			case E_COMPILE_WARNING :
			case E_USER_WARNING :
				$this -> error -> setType('WARNING');
			break;
		
			case E_NOTICE :
			case E_USER_NOTICE :
				$this -> error -> setType('INFO');
			break;
			
			case E_STRICT :
				$this -> error -> setType('STRICT');
			break;
		}

		$this -> action();
	}
134000
public static function error( $severity, $message, $file, $line ) {

		// Latest Twig raises a warning when accessing missing cached views - we can ignore it
		if( preg_match('/filemtime/', $message) )
			return;

		// if the error was a type hint failure then throw an InvalidArgumentException instead
		elseif( preg_match('/^Argument (\d+) passed to ([\w\\\\]+)::(\w+)\(\) must be an instance of ([\w\\\\]+), ([\w\\\\]+) given, called in ([\w\s\.\/_-]+) on line (\d+)/', $message, $m) )
			throw new \InvalidArgumentException("Argument {$m[1]} to {$m[2]}::{$m[3]}() should be an instance of {$m[4]}, {$m[5]} given", $severity, new \ErrorException($message, 0, $severity, $m[6], $m[7]));

		// convert the error to an exception
		throw new \ErrorException($message, 0, $severity, $file, $line);

	}
207587
public function errorHandler($errno, $errstr, $file, $line)
    {
        switch ($errno) {
            case E_USER_ERROR:
            case E_ERROR:
            case E_RECOVERABLE_ERROR:
                $this->logger->addError($errstr, array($file, $line));
                exit();
                break;
            case E_WARNING:
            case E_USER_WARNING:
                $this->logger->addWarning($errstr, array($file, $line));
                break;
            default:
                $this->logger->addInfo($errstr, array($file, $line));
                break;
        }
    }
28730
public function setError($message, $code, $exception = null) {

        $trace = null;
        $extra = "";

        if ($this->get('debug', 0)) {
            if (isset($exception)) {
                $trace = $exception->getTrace();
                $extra = str_replace(JPATH_ROOT, "", $exception->getFile()) . ":" . $exception->getLine();
            } else {
                $trace = array_slice(debug_backtrace(), 2);
            }
        }

        $this->error = array(
            'message'   => $message,
            'code'      => $code,
            'backtrace' => $trace,
            'extra'     => $extra
        );
    }
1144963
public function setErrorHandle($err, $message, $file, $line) {
        $oJsonRpc = JsonRpc::getInstance();
        $content = explode("\n", file_get_contents($file));
        header('Content-Type: application/json');
        $id = $oJsonRpc->extractId();
        $error = array(
           "code" => 100,
           "message" => "Server error",
           "error" => array(
              "name" => "PHPErorr",
              "code" => $err,
              "message" => $message,
              "file" => $file,
              "at" => $line,
              "line" => $content[$line-1]));
        ob_end_clean();
        echo $oJsonRpc->response(null, $id, $error);
        exit();
    }
223403
public function onError($code, $message, $file, $line)
    {
        $exception = $this->converter->convert($code, $message, $file, $line, debug_backtrace());
        $this->errbit->notify($exception);
    }
1355105
public function sendError($code, $message = null)
    {
        if ($this->ajaxOnly === false) {
            output()->setContentType('application/json');
        }

        if (is_array($code)) {
            if (is_numeric(key($code))) {
                $message = reset($code);
                $code = key($code);
            } elseif (isset($code[ 'code' ])) {
                $code = $code[ 'code' ];
                $message = $code[ 'message' ];
            }
        }

        output()->sendError($code, $message);
    }
937442
function log_exception($severity, $message, $filepath, $line)
	{
		$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];

		log_message('error', 'Severity: '.$severity.'  --> '.$message. ' '.$filepath.' '.$line, TRUE);
	}
612972
public static function lastErrorMsg($file,$message,$data) {
		Console::writeLine(PHP_EOL."<error>The JSON file, ".$file.", wasn't loaded. The error: ".$message."</error>");
		if ($message == "Syntax error, malformed JSON") {
			Console::writeLine("");
			$parser = new JsonLint\JsonParser();
			$error  = $parser->lint($data);
			Console::writeError($error->getMessage(), false, true);
		}
	}
256066
public static function handle($level, $message, $file, $line)
    {
        // respect error_reporting being disabled
        if (0 === error_reporting()) {
            return;
        }

        if (ini_get('xdebug.scream')) {
            $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be" .
            "\na legitimately suppressed error that you were not supposed to see.";
        }

        throw new ErrorException($message, 0, $level, $file, $line);
    }
1125835
public function setError(int $type, string $message, string $file, int $line, string $class, array $trace = [])  : array
    {
        return $this->errors = [
            'type'    => $type,
            'message' => $message,
            'file'    => $file,
            'line'    => $line,
            'class'   => $class,
            'trace'   => $trace,
        ];
    }