Commit 29d3f36b authored by 王源's avatar 王源 🎧

修改错误信息默认返回格式

parent d3b6f06b
......@@ -38,12 +38,7 @@ class AppExceptionHandler extends ExceptionHandler
$this->stdoutLogger->error($msg);
$this->logger->error($msg);
$this->stdoutLogger->error($throwable->getTraceAsString());
// 格式化输出
$data = json_encode([
'code' => $throwable->getCode() ?: 400,
'msg' => $throwable->getMessage(),
], JSON_UNESCAPED_UNICODE);
return $response->withAddedHeader('content-type', 'application/json')->withBody(new SwooleStream($data));
return $response->withStatus(500)->withBody(new SwooleStream($msg));
}
public function isValid(Throwable $throwable): bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment