Bug #62420 [Opn->Wfx]: Exception::__toString() creates message in wrong order if prev exception exists
Edit report at https://bugs.php.net/bug.php?id=62420&edit=1
ID: 62420
Updated by: fa@php.net
Reported by: bugs dot php at mohiva dot com
Summary: Exception::__toString() creates message in wrong
order if prev exception exists
-Status: Open
+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:
While you are correct that it might be more logical to reverse the order, this
isn't a huge problem.
Previous Comments:
------------------------------------------------------------------------
[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
Thread (3 messages)