1--TEST--
2ZE2 catch exception thrown in destructor
3--FILE--
4<?php
5
6class FailClass
7{
8    public $fatal;
9
10    function __destruct()
11    {
12        echo __METHOD__ . "\n";
13        throw new exception("FailClass");
14        echo "Done: " . __METHOD__ . "\n";
15    }
16}
17
18try
19{
20    $a = new FailClass;
21    unset($a);
22}
23catch(Exception $e)
24{
25    echo "Caught: " . $e->getMessage() . "\n";
26}
27
28class FatalException extends Exception
29{
30    function __construct($what)
31    {
32        echo __METHOD__ . "\n";
33        $o = new FailClass;
34        unset($o);
35        echo "Done: " . __METHOD__ . "\n";
36    }
37}
38
39try
40{
41    throw new FatalException("Damn");
42}
43catch(Exception $e)
44{
45    echo "Caught Exception: " . $e->getMessage() . "\n";
46}
47catch(FatalException $e)
48{
49    echo "Caught FatalException: " . $e->getMessage() . "\n";
50}
51
52?>
53--EXPECT--
54FailClass::__destruct
55Caught: FailClass
56FatalException::__construct
57FailClass::__destruct
58Caught Exception: FailClass
59