ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[Xunsearch PHP-SDK](http://www.xunsearch.com) v1.4.8 API 参考文档 # XSErrorException [All Packages](#)| [属性](#)| [方法(函数)](#) | 包 | [XS](#) | |-----|-----| | 继承关系 | class XSErrorException »[XSException](#) »Exception | | 版本 | 1.0.0 | | 源代码 | [sdk/php/lib/XS.class.php](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XS.class.php) | XS 错误异常类定义, XS 所有操作过程发生错误均抛出该实例 ### Protected 属性 [隐去继承来的属性](#) | 名称 | 类型 | 描述 | 定义于 | |-----|-----|-----|-----| | code | | | Exception | | file | | | Exception | | line | | | Exception | | message | | | Exception | ### Public 方法 [隐去继承来的方法](#) | 名称 | 描述 | 定义于 | |-----|-----|-----| | [__construct()](#) | 构造函数 | XSErrorException | | [__toString()](#) | 将类对象转换成字符串 | XSErrorException | | getCode() | | Exception | | getFile() | | Exception | | getLine() | | Exception | | getMessage() | | Exception | | getPrevious() | | Exception | | [getRelPath()](#) | 取得相对当前的文件路径 | [XSException](#) | | getTrace() | | Exception | | getTraceAsString() | | Exception | ### 方法明细 __construct()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public void <b>__construct</b>(int $code, string $message, string $file, int $line, Exception $previous=NULL)</div></td></tr><tr><td class="paramNameCol">$code</td> <td class="paramTypeCol">int</td> <td class="paramDescCol">出错代码</td></tr><tr><td class="paramNameCol">$message</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">出错信息</td></tr><tr><td class="paramNameCol">$file</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">出错所在文件</td></tr><tr><td class="paramNameCol">$line</td> <td class="paramTypeCol">int</td> <td class="paramDescCol">出错所在的行数</td></tr><tr><td class="paramNameCol">$previous</td> <td class="paramTypeCol">Exception</td> <td class="paramDescCol"></td></tr></table> **源码:**[sdk/php/lib/XS.class.php#L134](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XS.class.php#L134) (**[显示](#)**) `public function __construct($code, $message, $file, $line, $previous = null) {     $this->_file = $file;     $this->_line = $line;     if (version_compare(PHP_VERSION, '5.3.0', '>=')) {         parent::__construct($message, $code, $previous);     } else {         parent::__construct($message, $code);     } }` 构造函数将 $file, $line 记录到私有属性在 __toString 中使用 __toString()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public string <b>__toString</b>()</div></td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">异常的简要描述信息</td></tr></table> **源码:**[sdk/php/lib/XS.class.php#L149](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XS.class.php#L149) (**[显示](#)**) `public function __toString() {     $string = '[' . __CLASS__ . '] ' . $this->getRelPath($this->_file) . '(' . $this->_line . '): ';     $string .= $this->getMessage() . '(' . $this->getCode() . ')';     return $string; }` 将类对象转换成字符串 Copyright © 2008-2011 by [杭州云圣网络科技有限公司](http://www.xunsearch.com) All Rights Reserved.