|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-07-24 08:28 UTC] fa@php.net
[2012-07-24 08:28 UTC] fa@php.net
-Status: Open
+Status: Wont fix
[2012-07-25 14:11 UTC] bugs dot php at mohiva dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 23:00:01 2025 UTC |
Description: ------------ The method Exception::__toString() creates the message in the wrong order if a previous exception exists in the Exception object. The message contains the message from the previous exception as first and then marked as next exception the message from the exception object itself. Normally the message from the current exception should be the first message followed by the previous message and so one. Test script: --------------- <?php try { throw new Exception("Previous exception"); } catch (Exception $previous) { $current = new Exception("Current exception", 0, $previous); echo 'Previous:' . $current->getPrevious()->getMessage() . '<br />'; echo 'Current:' . $current->getMessage() . '<br />'; echo 'String:' . $current->__toString() . '<br />'; } Expected result: ---------------- Previous: Previous exception -------------------------------------------------------------- Current: Current exception -------------------------------------------------------------- String: exception 'Exception' with message 'Current exception' in exception.php:4 Stack trace: #0 {main} Next exception 'Exception' with message 'Previous exception' in exception.php:6 Stack trace: #0 {main} Actual result: -------------- Previous: Previous exception -------------------------------------------------------------- Current: Current exception -------------------------------------------------------------- String: exception 'Exception' with message 'Previous exception' in exception.php:4 Stack trace: #0 {main} Next exception 'Exception' with message 'Current exception' in exception.php:6 Stack trace: #0 {main}