改进 错误返回

This commit is contained in:
iVampireSP.com 2022-09-09 01:32:42 +08:00
parent a5f4facead
commit a2e65e688a
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -49,6 +49,17 @@ public function report(Throwable $exception)
*/
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
$rendered = parent::render($request, $exception);
return response()->json(
[
'error' => [
'code' => $rendered->getStatusCode(),
'message' => $exception->getMessage(),
]
],
$rendered->getStatusCode()
);
}
}