错误处理
@param $code
@param $message
@param $file
@param $line
@throws \Exception
182244
public function error($code, $message, $file, $line)
    {
        if ($code && error_reporting()) {
            if (X_DEBUG && PHP_SAPI !='cli') {
                $error = self::getComponent('errorHandler');
                $error->displayError($code, $message, $file, $line);
            } else if(PHP_SAPI =='cli'){
                echo $message;
            }else {
                $errorCallBack = \X\Router::$error_callback;
                if ($errorCallBack) {
                    call_user_func($errorCallBack, ['message' => $message, 'file' => $file, 'line' => $line]);
                    exit;
                } else {
                    echo '<fieldset style="background: #F3F3F3">';
                    echo '<legend style="color:red;">error[' . $code . ']</legend>';
                    echo '<p>' . $message . '  (' . $file . '[' . $line . '])</p>';
                    echo '</fieldset>';

                    echo '<fieldset style="background: #ddd;">';
                    echo '<legend style="color:#800000">trace</legend>';
                    echo '<pre>';
                    debug_print_backtrace();
                    echo '</pre>';
                    echo '</fieldset>';
                }
            }
        }
    }
692799
public function showCode($file, $line)
    {
        $line = $line - 1; //数组下标从0开始的
        $contentArr = file($file);
        foreach ($contentArr as $k => $v) {
            if ($k > $line - $this->maxLine) {
                echo '<span class="line">' . ($k + 1) . '</span>' . $v;
            }
            if ($k == $line - 1) {
                break;
            }
        }
        echo '<span class="errorLine"><span class="line">' . ($line + 1) . '</span>' . $contentArr[$line] . '</span>';
        foreach ($contentArr as $k => $v) {
            if ($k > $line) {
                echo '<span class="line">' . ($k + 1) . '</span>' . $v;
            }
            if ($k == $line + $this->maxLine) {
                break;
            }
        }

    }
1124829
public static function onError( $code, $message, $file = null, $line = null, $context = null )
    {
        $_trace = \debug_backtrace();
        $_traceText = static::_cleanTrace( $_trace, 3 );

        if ( E_NOTICE == $code )
        {
            //return false;
        }

        static::$_error = array(
            'code'       => $code,
            'type'       => null,
            'message'    => $message,
            'file'       => $file,
            'line'       => $line,
            'trace'      => $_traceText,
            'traces'     => $_trace,
            'source'     => static::_getCodeLines( $file, $line, static::$_sourceLines ),
            'start_line' => static::$_startLine,
        );

        Log::error( static::$_error['message'] . ' (' . static::$_error['code'] . ')' );

        return static::renderError();
    }
894100
public static function displayError($code,$message,$file,$line)
    {
        if(YII_DEBUG) {
            echo "<h1>PHP Error [$code]</h1>\n";
            echo "<p>$message ($file:$line)</p>\n";
            echo '<pre>';

            $trace=debug_backtrace();
            // skip the first 3 stacks as they do not tell the error position
            if(count($trace)>3)
                $trace=array_slice($trace,3);
            foreach($trace as $i=>$t) {
                if(!isset($t['file']))
                    $t['file']='unknown';
                if(!isset($t['line']))
                    $t['line']=0;
                if(!isset($t['function']))
                    $t['function']='unknown';
                echo "#$i {$t['file']}({$t['line']}): ";
                if(isset($t['object']) && is_object($t['object']))
                    echo get_class($t['object']).'->';
                echo "{$t['function']}()\n";
            }

            echo '</pre>';
        } else {
            echo "<h1>PHP Error [$code]</h1>\n";
            echo "<p>$message</p>\n";
        }
    }
542658
protected function write($line, $expectedCode = null, $message = null)
    {
        fwrite($this->_connection, $line . "\r\n");
        if (!$expectedCode) {
            return;
        }
        $response = $this->read();
        if (!in_array((int) $response, (array) $expectedCode, true)) {
            throw new NetException('SMTP server did not accept ' . ($message ? $message : $line) . ' with error: ' . trim($response));
        }
    }
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();
	}
88368
protected function _createTranslationException($message, $code = 0, \Exception $previous = null, $subject = null, TranslatorInterface $translator = null)
    {
        return new TranslationException($message, $code, $previous, $subject, $translator);
    }
1271102
private function curlException($message, $code) {
        if (!array_key_exists($code, $this->getExceptionCodeMappings())) throw new CurlExceptions\CurlException("Error: {$message} and the Error no is: {$code} ", $code);

        $exceptionClass = $this->exceptionsNamespace . '\\' . $this->getExceptionCodeMappings()[$code];
        if (!class_exists($exceptionClass)) throw new \RuntimeException(
            $exceptionClass . ' does not exist. Check class var $exceptionCodeMappings in Circle\RestClientBundle\Traits\Exceptions.'
        );
        throw new $exceptionClass($message, $code);

    }
560236
public static function throw(string $message, int $code = 1, string $type = '', string $secondMessage = '') {
        throw new static($message, $code, $type, $secondMessage);
    }
588342
public function handleFatalError($code, $description, $file = null, $line = null)
    {
        $exception = new FatalErrorException($description, $code, $file, $line);

        return $this->handle($exception);
    }
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);
	}
823515
protected function connectionErrorHandler($code, $message, $file, $line, $args)
    {
        $this->connectionErrors[] = [
            'code' => $code,
            'message' => $message,
            'file' => $file,
            'line' => $line,
            'args' => $args
        ];
    }
1268300
public function handle($type, $message, $file, $line)
    {
        if (self::$catch & $type > 0) {
            self::$error = $message;
            return;
        }
        switch ($type) {
            case E_USER_NOTICE:
            case E_USER_DEPRECATED:
            case E_USER_WARNING:
            case E_USER_ERROR:
                $backtrace = debug_backtrace();
                if (isset($backtrace[2]['file'])) {
                    $file = $backtrace[2]['file'];
                }
                if (isset($backtrace[2]['line'])) {
                    $line = $backtrace[2]['line'];
                }
                break;
        }
        switch ($type) {
            case E_USER_ERROR:
            case E_ERROR:
            case E_RECOVERABLE_ERROR:
                throw new ErrorException($message, 0, $type, $file, $line);
            default:
                $this->logger->log($this->map[$type], self::$strings[$type] . ': ' . $message, array(
                    'file' => $file,
                    'line' => $line,
                    'code' => $type
                ));
        }
    }
1120573
public function trace( string $file, int $line, string $target, string $message, string $tag = NULL )
    {
        self::log( $file, $line, "T:$target", $message, $tag );
    }
615181
public function logException($messageException = null, $method = null, $line = null)
    {
        if (self::getConfig('log', 'exception')) {
            $this->logMessage("EXCEPTION", "Exception find : {$messageException} --- " . $this->__toString(), $method, $line);
        }
    }
423654
protected function write($messages, $file)
    {
        $f = @fopen($file, 'a');
        if ($f === false)
        {
            throw new \Exception("Logfile $file is not writeable!");
        }

        foreach($messages as $msg)
        {
            fwrite($f, $msg);
        }

        fclose($f);
    }
914104
public function handleError($level, $message, $file, $line)
    {
        if (error_reporting() & $level) {
            $exception_level = isset($this->levels[$level]) ? $this->levels[$level] : $level;

            throw new \ErrorException(
                sprintf('%s: %s in %s line %d', $exception_level, $message, $file, $line),
                0,
                $level,
                $file,
                $line
            );
        }
    }