You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
759 B
PHP

This file contains ambiguous Unicode characters!

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);
}
}