构造PHP的异常有第三个参数,documentation说:如何实现异常链在PHP
$previous: The previous exception used for the exception chaining.
但我不能使它发挥作用。我的代码看起来像这样:
try
{
throw new Exception('Exception 1', 1001);
}
catch (Exception $ex)
{
throw new Exception('Exception 2', 1002, $ex);
}
我期待异常2被抛出,我期望它会有异常1附加。但我得到的是:
Fatal error: Wrong parameters for Exception([string $exception [, long $code ]]) in ...
我在做什么错了?
什么是您的PHP版本? – EFraim 2010-04-09 08:50:11