31 lines
648 B
PHP
31 lines
648 B
PHP
<?php
|
|
|
|
|
|
namespace app\admin\exception;
|
|
|
|
|
|
use think\Container;
|
|
use think\Response;
|
|
|
|
class LogicException extends \Exception implements RenderException
|
|
{
|
|
|
|
public $errors;
|
|
|
|
public function __construct($msg = '',$code = 500,$errors = [])
|
|
{
|
|
parent::__construct($msg,$code);
|
|
$this->errors = $errors;
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
$data['code'] = $this->getCode();
|
|
$data['msg'] = $this->getMessage();
|
|
$data['data'] = $this->errors;
|
|
if (Container::get('app')->isDebug()){
|
|
$data['trace'] = $this->getTrace();
|
|
}
|
|
return Response::create($data,'json');
|
|
}
|
|
} |