is("api/*")) { //如果错误是 ValidationException的一个实例,说明是一个验证的错误 if ($exception instanceof ValidationException) { return out(null, 10000, array_values($exception->errors())[0][0]); } if ($exception instanceof ExitOutException){ $msg = $exception->getMessage(); $out = json_decode($msg, true); return out($out['data'], $out['status'], $out['message']); } } return parent::render($request, $exception); } }