Bug #62420 [Wfx]: Exception::__toString() creates message in wrong order if prev exception exists
| From: | bugs dot php at mohiva dot com | Date: | Wed, 25 Jul 2012 14:11:38 +0000 |
| Subject: | Bug #62420 [Wfx]: Exception::__toString() creates message in wrong order if prev exception exists | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-172230@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62420&edit=1
ID: 62420
User updated by: bugs dot php at mohiva dot com
Reported by: bugs dot php at mohiva dot com
Summary: Exception::__toString() creates message in wrong
order if prev exception exists
Status: Wont fix
Type: Bug
Package: *General Issues
Operating System: Gentoo Linux
PHP Version: 5.4.4
Block user comment: N
Private report: N
New Comment:
I think with this behaviour it is really hard to find bugs and it has a huge WTF factor when you
look into your log files and then you see the exception messages in a reverse order.
Is it really too hard to fix?
Previous Comments:
------------------------------------------------------------------------
[2012-07-24 08:28:41] fa@php.net
While you are correct that it might be more logical to reverse the order, this
isn't a huge problem.
------------------------------------------------------------------------
[2012-06-26 11:56:09] bugs dot php at mohiva dot com
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}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62420&edit=1