【发布时间】:2017-05-31 10:09:30
【问题描述】:
我们多年的 PHP 代码一直在大量使用异常处理,通过 set_error_handler() 和 set_exception_handler() 将传统错误转换为异常。在为我们的一些服务器迁移到 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版本