ID: 34538 Updated by: [EMAIL PROTECTED] Reported By: ts at siteartwork dot de -Status: Open +Status: Bogus Bug Type: Feature/Change Request -Operating System: Win XP +Operating System: * -PHP Version: 5.1.0RC1 +PHP Version: 5.* -Assigned To: +Assigned To: helly New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Exceptions are write once (constructor) and read multiple (access methods). This is necessary because a missuse might otherwise most likely result in an immediate SEGV or even worse a security issue. But anyway is the need to overwrite information passed along with an exception a sign for a design flaw. Exceptions are not meant to transport parameters. In general follow these rules: 1) Exceptions are Exceptions 2) Never Exceptions for control flow 3) Never ever use Exceptions for parameter passing Previous Comments: ------------------------------------------------------------------------ [2005-09-17 18:40:01] ts at siteartwork dot de Description: ------------ The declaration of getMessage() as final in the SPLs Exception class makes it impossible to encapsulate other (Userland-)Exceptions and provide appropriate functionality. Reproduce code: --------------- <?php class UserException extends Exception { private $encapsulatedException = null; public function __construct($message = null, $e = null) { if ($e !== null && ($e instanceof Exception) { $this->encapsulatedException = $e; } else { $this->encapsulatedException = null; } parent::__construct($message); } public function getMessage() { $message = parent::getMessage(); if ($message == null && $this->encapsulatedException !== null) { echo $this->encapsulatedException->getMessage(); } } } ?> Expected result: ---------------- It should be possible to override the getMessage()-method to decide wether to return the message the object was instantiated with or the message of the encapsulated Exception. Actual result: -------------- Fatal error: Cannot override final method Exception::getMessage() ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34538&edit=1
