我们多年的PHP代码通过set_error_handler()和set_exception_handler()将传统错误转换为异常,从而大量使用异常处理。移植到PHP 7对一些我们的服务器后,像这样的错误,开始抽不出来:将PHP 7错误对象转换为异常?
Uncaught TypeError: Argument 1 passed to DataStellar\General\Exception_Handler::getContext() must be an instance of Exception, instance of Error given
我们可以用\ Throwable作为类型提示,但大多数的我们的代码库仍然对PHP 5的服务器。
有什么办法可以轻松地将Error对象转换为Exception对象吗?
升级你的服务器或降级你的php版本 – samayo