Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.15

Bug #5330 echo Pear_Exception doesn't show message
Submitted: 2005-09-08 08:54 UTC
From: php at adaniels dot nl Assigned: cellog
Status: Closed Package: PEAR
PHP Version: 5.0.5 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2005-09-08 08:54 UTC] php at adaniels dot nl
Description: ------------ version: PEAR-1.3.6 The message as well as the class name of the exception are not shown when echo-ing a Pear_Exception. PS. To output valid HTML, the table should have summary attribute. Test script: --------------- <?php require_once('PEAR/Exception.php'); class myException extends PEAR_Exception {} throw new myException("I would like to see this message"); ?> Expected result: ---------------- <b>Fatal error</b>: Uncaught 'myException' with message 'I would like to see this message'<table border="1" cellspacing="0" summary="Backtrace for uncaught Pear_Exception"> <tr><td colspan="3" bgcolor="#aaaaaa" align="center"><b>Exception trace</b></td></tr> <tr><td align="center" bgcolor="#cccccc" width="20"><b>#</b></td><td align="center" bgcolor="#cccccc"><b>Function</b></td><td align="center" bgcolor="#cccccc"><b>Location</b></td></tr> <tr><td align="center">0</td><td>unknown()</td><td>/var/www/seabert/webroot/ontwikkeling/djaboo2/test.php:3</td></tr> <tr><td align="center">1</td><td>{main}</td><td> </td></tr> </table> thrown in <b>/var/www/seabert/webroot/ontwikkeling/djaboo2/test.php</b> on line <b>3</b><br /> Actual result: -------------- <b>Fatal error</b>: Uncaught <table border="1" cellspacing="0"> <tr><td colspan="3" bgcolor="#aaaaaa" align="center"><b>Exception trace</b></td></tr> <tr><td align="center" bgcolor="#cccccc" width="20"><b>#</b></td><td align="center" bgcolor="#cccccc"><b>Function</b></td><td align="center" bgcolor="#cccccc"><b>Location</b></td></tr> <tr><td align="center">0</td><td>unknown()</td><td>/var/www/seabert/webroot/ontwikkeling/djaboo2/test.php:3</td></tr> <tr><td align="center">1</td><td>{main}</td><td> </td></tr> </table> thrown in <b>/var/www/seabert/webroot/ontwikkeling/djaboo2/test.php</b> on line <b>3</b><br />

Comments

 [2005-09-08 09:13 UTC] info at adaniels dot nl
Solution: Add $causes[] = $cause; ---------- /** * Function must be public to call on caused exceptions * @param array */ public function getCauseMessage(&$causes) { $trace = $this->getTraceSafe(); $cause = array('class' => get_class($this), 'message' => $this->message, 'file' => 'unknown', 'line' => 'unknown'); if (isset($trace[0])) { if (isset($trace[0]['file'])) { $cause['file'] = $trace[0]['file']; $cause['line'] = $trace[0]['line']; } } $causes[] = $cause; //<---- Added if ($this->cause instanceof PEAR_Exception) { $this->cause->getCauseMessage($causes); } if (is_array($this->cause))
 [2005-09-13 04:59 UTC] cellog
this is already fixed in PEAR 1.4.x. Version 1.4.0 stable is due out quite soon