Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Laravel 框架和 Dingo API 库构建一个 REST API。除了我不知道在发生异常时如何自定义默认错误处理程序之外,一切都运行良好。
例如,当我的代码运行错误时,响应很简单:
{ "message": "Error", "status_code": 500 }
如何将此响应更改为我自己的格式?
'错误格式' => [ '消息' => ':消息', '错误' => ':错误', '代码' => 0, 'status_code' => ':status_code', '结果' => ':错误', '调试' => ':调试', ],