情景介绍:url请求是get方式,此次报错是测试post请求,异常返回错误信息是否正确,结果异常返回信息有误,返回信息不正确。
以下下报错信息,显示 自定义全局异常报错信息是传入HttpException参数给app\lib\exception\ExceptionHandle::render() 方法(本应传入think\Exception类型的参数),结果异常信息不能自动转换成正确的信息,查看think\Exception 和 HttpException 两个class类,都同时继承了\exception基类,也就是think\Exception 和 HttpException 两个class类并没有继承关系,二者互不关联,所以参数类型不能识别,将app\lib\exception\ExceptionHandle::render()的参数改为以基类的方式参数传入,就可解决此问题。
think\exception\ErrorException' with message 'Argument 1 passed to app\lib\exception\ExceptionHandle::render() must be an instance of think\Exception
think\exception\ErrorException: Argument 1 passed to app\lib\exception\ExceptionHandle::render() must be an instance of think\Exception, instance of think\exception\HttpException given,