matthewerskine / json-error-renderer
一个简单的辅助工具,用于Laravel/Lumen,允许将错误以JSON格式渲染。
1.0.0
2018-05-25 10:20 UTC
Requires (Dev)
- phpunit/phpunit: ^7.1
This package is not auto-updated.
Last update: 2024-09-29 05:42:01 UTC
README
这是一个简单的包,提供了一个静态辅助类,用于生成适合快速以JSON格式渲染的错误。
在Laravel/Lumen应用程序中使用
在 app/Exceptions/Handler.php
中
use MatthewErskine\JsonErrorRenderer\JsonErrorRenderer; public function render($request, Exception $e) { $error = JsonErrorRenderer::render($request, $e); return response()->json( $error->getPayload(), $error->getStatusCode() ); }