handleExceptionUtil:
if ($e instanceof ExceptionUtil) {
//自定义错误
$this->httpCode = $e->httpCode;
$this->code = $e->code;
return show($e->getMessage(), $this->code, [], $this->httpCode);
} else {
//系统错误
$err = [
'msg' => $e->getMessage(),
'line' => $e->getLine(),
'file' => $e->getFile(),
'params' => json_encode(Request::param()),
];
LogUtil::error($err);
return show('系统异常', $this->code, [], $this->httpCode);
}ExceptionUtil:public function __construct($message = '', $httpCode = 0, $code = 0)
{
$this->httpCode = empty($httpCode) ? $this->httpCode : $httpCode;
$this->message = $message;
$this->code = empty($code) ? $this->code : $code;
}我在我的mac(php7.2+nginx1.17)环境下能正常抛出{
"httpCode": 200,
"status": 1,
"message": "接口名称不能为空",
"data": [
]
}但把代码传到linux下(php7.2+nginx1.16)就抛出的是html错误了。。
内容是一样的,但一个是json,一个是HTML 真不知道是什么原因了??
解决了,use的时候大小写的问题 ,重写了一个在对比出来。。。无奈!!
最佳答案