|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-08-08 17:13 UTC] david at grudl dot com
Description: ------------ Chained exceptions are printed in uncommon order (from inner to outer exception). This makes me confused :-( Reference: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Throwable.html#printStackTrace() Reproduce code: --------------- try { throw new FileNotFoundException("File not found."); } catch (FileNotFoundException $e) { throw new ConfigException("Missing configuration.", 0, $e); } echo $e; // note $e is ConfigException! Expected result: ---------------- exception 'FileNotFoundException' with message 'File not found.' in demo.php:8 Stack trace: #0 demo.php(17): ... #1 {main} Next exception 'ConfigException' with message 'Missing configuration.' in demo.php:21 Stack trace: #0 demo.php(28): .... #1 {main} Actual result: -------------- exception 'ConfigException' with message 'Missing configuration.' in demo.php:21 Stack trace: #0 demo.php(28): .... #1 {main} previous exception 'FileNotFoundException' with message 'File not found.' in demo.php:8 Stack trace: #0 demo.php(17): ... #1 {main} PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 09:00:01 2025 UTC |
Reproduce code: <?php class LowException extends Exception { } class HighException extends Exception { } $e = new LowException("File not found."); $e = new HighException("Missing configuration.", 0, $e); echo $e; // $e is HighException instance ?> Expected result: ---------------- exception 'HighException' with message 'Missing configuration.' in test.php:13 Stack trace: #0 {main} Previous exception (or "Caused by") 'LowException' with message 'File not found.' in test.php:11 Stack trace: #0 {main} Actual result: --------------- exception 'LowException' with message 'File not found.' in test.php:11 Stack trace: #0 {main} Next exception 'HighException' with message 'Missing configuration.' in test.php:13 Stack trace: #0 {main} Description: ------------ The first (and most appealing) line of textual output begins with "exception 'LowException' with message ...", but the printed exception is 'HighException'. This order makes output less evident.