php继承类报错,自定义 thinkphp5.0全局异常报错,继承基类\exception解决

情景介绍: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,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值