laravel自定义接口错误响应格式
- 基础小知识
- 1.在 app/Exceptions 下新建 ApiException
- 2.在\vendor\laravel\framework\src\Illuminate\Foundation\ helpers.php 中增加函数:(或者直接写在这个异常类中,私有调用)
- 3.使用ApiException类
- 4.路由预览效果
- 5.传递参数
-
- 1 参数传 string
- 2 参数传 string,code (自定义错误码,非 httpStatus)
- 3 参数传 string,code(httpStatus)
- 4 参数传 array
- 5 参数传 array,code(httpStatus)
- 6 参数传 string,code