successed();
{
"msg": "success", "code": 200, "data": {}
}
$this->internalError();
{ "msg": "服务器错误...", "code": 500, "data": {} }
$this->notFond();
{ "msg": "未找到", "code": 404, "data...common\exception\Handler
异常处理控制后, 可定制化异常处理
见: http://surest.cn/archives/85/
简单说明一下:
在 handler.php 通过传递当前抛出异常的...exception 和我们需要针对化处理的异常进行校验, 采用的也就是 instanceof 去判断来自于哪个异常
这样做的好处就是, 针对不用的异常进行监控, 并抛出指定的异常错误信息 或者 日志...自定义的异常处理 必须 继承 CustomExceptionInterface 接口, 通过 showMsg 来处理抛出异常
代码中, 我们会发现一个问题, 在 handler.php 中 异常信息是返回的