在app.php中添加:
// 异常处理handle类 留空使用 \think\exception\Handle
'exception_handle' => function($e) {
// 参数验证错误
return json([
'msg'=>'服务器异常,原因:'.$e->getMessage(),
'code'=>'500',
'result'=>'',
]);
},
详见:
官网说明