Browse Source
- MFH Exception handling
- MFH Exception handling
[DOC] - Exceptions can be thrown while exceptions are pending, they are linked - Exceptions can be handled in __destruct - Add optional Exception $previous parameter to . Exception::__construct . ErrorException::__constructPECL
6 changed files with 117 additions and 22 deletions
-
36Zend/tests/exception_007.phpt
-
36Zend/tests/exception_008.phpt
-
12Zend/tests/gc_030.phpt
-
38Zend/zend_exceptions.c
-
2Zend/zend_exceptions.h
-
15Zend/zend_objects.c
@ -0,0 +1,36 @@ |
|||
--TEST-- |
|||
Setting previous exception |
|||
--FILE-- |
|||
<?php |
|||
|
|||
try { |
|||
try { |
|||
throw new Exception("First", 1, new Exception("Another", 0, NULL)); |
|||
} |
|||
catch (Exception $e) { |
|||
throw new Exception("Second", 2, $e); |
|||
} |
|||
} |
|||
catch (Exception $e) { |
|||
throw new Exception("Third", 3, $e); |
|||
} |
|||
|
|||
?> |
|||
===DONE=== |
|||
--EXPECTF-- |
|||
Fatal error: Uncaught exception 'Exception' with message 'Another' in %sexception_007.php:%d |
|||
Stack trace: |
|||
#0 {main} |
|||
|
|||
Next exception 'Exception' with message 'First' in %sexception_007.php:%d |
|||
Stack trace: |
|||
#0 {main} |
|||
|
|||
Next exception 'Exception' with message 'Second' in %sexception_007.php:%d |
|||
Stack trace: |
|||
#0 {main} |
|||
|
|||
Next exception 'Exception' with message 'Third' in %sexception_007.php:%d |
|||
Stack trace: |
|||
#0 {main} |
|||
thrown in %sexception_007.php on line %d |
|||
@ -0,0 +1,36 @@ |
|||
--TEST-- |
|||
Exception in __destruct while exception is pending |
|||
--FILE-- |
|||
<?php |
|||
|
|||
class TestFirst |
|||
{ |
|||
function __destruct() { |
|||
throw new Exception("First"); |
|||
} |
|||
} |
|||
|
|||
class TestSecond |
|||
{ |
|||
function __destruct() { |
|||
throw new Exception("Second"); |
|||
} |
|||
} |
|||
|
|||
$ar = array(new TestFirst, new TestSecond); |
|||
|
|||
unset($ar); |
|||
|
|||
?> |
|||
===DONE=== |
|||
--EXPECTF-- |
|||
Fatal error: Uncaught exception 'Exception' with message 'First' in %sexception_008.php:%d |
|||
Stack trace: |
|||
#0 %sexception_008.php(%d): TestFirst->__destruct() |
|||
#1 {main} |
|||
|
|||
Next exception 'Exception' with message 'Second' in %sexception_008.php:%d |
|||
Stack trace: |
|||
#0 %sexception_008.php(%d): TestSecond->__destruct() |
|||
#1 {main} |
|||
thrown in %sexception_008.php on line %d |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue