From:             bugs dot php at mohiva dot com
Operating system: Gentoo Linux
PHP version:      5.4.4
Package:          *General Issues
Bug Type:         Bug
Bug description:Exception::__toString() creates message in wrong order if prev 
exception exists

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 bug report at https://bugs.php.net/bug.php?id=62420&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=62420&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=62420&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=62420&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=62420&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62420&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=62420&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=62420&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=62420&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=62420&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=62420&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=62420&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=62420&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=62420&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=62420&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=62420&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62420&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=62420&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=62420&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=62420&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=62420&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=62420&r=mysqlcfg

Reply via email to