1、修改configuration里面的配置
- 异常处理handle类 留空使用 \think\exception\Handle
‘exception_handle’ => ‘app\exception\ExceptionHandler’, //这里是你自己的异常类重写的目录
<?php
/**
- Created by PhpStorm.
- User: admin
- Date: 2018/9/23
- Time: 22:43
*/
namespace app\exception;
use think\Exception;
use think\exception\Handle;
use think\Log;
use think\Request;
class ExceptionHandler extends Handle
{
private $code;
private $msg;
private $errorCode;
/**继承并重写Exception类
* @param Exception $ex
* @return \think\Response|\think\response\Json
*/
public function render(\Exception $ex)
{
if ($ex instanceof BaseException) {
$this->msg = $ex->code;
$this->msg = $ex->msg;
$this->errorCode = $ex->errorCode;
} else {
i