Exception without message yields wierd wording in error message

From: Date: Sun, 30 Nov 2003 11:14:27 +0000
Subject: Exception without message yields wierd wording in error message
Groups: php.internals 
Request: Send a blank email to internals+get-5822@lists.php.net to get a copy of this message
When I throw an exception which is derived from the internal Exception class and implement __toString but do not return a value, the reported error (in case I don't catch the exception) is: Fatal error: Uncaught thrown in /home/mfischer/htdocs/php5/MySQL.php on line 8 i.e. the word 'exception' is missing (and there's redundant line break it seems). Example is from: <?php class MyException extends Exception { function __toString() { return ""; } } throw new MyException; ?> If I throw some other object not derived from Exception (e.g. stdClass) I get this (which makes more sense): $ php -r 'throw new stdClass;' Fatal error: Uncaught exception 'stdClass' in Unknown on line 0 What I want to say is, that I think it would be a good idea to print out "Fatal error: Uncaught exception '<classname>' thrown in .." even if __toString is not implemented. Just for consistency. Another thing I observed is the preserving of the case of the classname. If I throw e.g. stdClass, the case is preserved; but not if I throw my own class: $ php -r 'throw new stdClass;' Fatal error: Uncaught exception 'stdClass' in Unknown on line 0 versus $ php -r 'class MyEx extends Exception {}; throw new MyEx;' Fatal error: Uncaught exception 'myex' with message 'Unknown exception' in Command line code:1 Stack trace: #0 {main} thrown in Command line code on line 1 This all may be sound like nitpicking but I think for consistency and if it's not too complex these small things should be looked into. cheers, - Markus

« previous php.internals (#5822) next »