This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
<?php
namespace app\common\exception;
use think\Exception;
class ServiceException extends Exception
{
public $message = '';
public $httpCode = 500;
public $code = 500;
public function __construct($message = '', $httpCode = 500, $code = 500){
$this->message = $message;
$this->httpCode = $httpCode;
$this->code = $code;
$this->render();
}
/**
* 针对swoole,配置中app里设置exception_handle始终无效,只能先手动把消息设置成固定格式
*/
protected function render()
$data = [
'status' => $this->code,
'message' => $this->message,
'data' => [],
];
$this->message = json_encode($data);