Jos*_*ábl 14 php exception chaining
PHP异常的构造函数有第三个参数,文档说:
$previous: The previous exception used for the exception chaining.
Run Code Online (Sandbox Code Playgroud)
但我不能让它发挥作用.我的代码看起来像这样:
try
{
throw new Exception('Exception 1', 1001);
}
catch (Exception $ex)
{
throw new Exception('Exception 2', 1002, $ex);
}
Run Code Online (Sandbox Code Playgroud)
我希望抛出异常2,我希望它会附加异常1.但我得到的只是:
Fatal error: Wrong parameters for Exception([string $exception [, long $code ]]) in ...
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
| 归档时间: |
|
| 查看次数: |
6655 次 |
| 最近记录: |