note 99702 added to language.exceptions

From: Date: Tue, 31 Aug 2010 17:21:27 +0000
Subject: note 99702 added to language.exceptions
Groups: php.notes 
Request: Send a blank email to php-notes+get-172207@lists.php.net to get a copy of this message
Watch your namespace if you have created your own exception class. For example: Error.php <?php namespace Global; class Error extends Exception {} Foo.php <?php namespace Foo; try { $this->foo(); } catch (Error $e) { echo $e->getMessage(); } You WILL NOT get an error message if Error is not in the Foo namespace. Instead the Exception will be passed upwards. Should be: try { $this->foo(); } catch (Global\Error $e) { echo $e->getMessage(); } ---- Server IP: 69.147.83.197 Probable Submitter: 152.10.148.107 ---- Manual Page -- http://www.php.net/manual/en/language.exceptions.php Edit -- https://master.php.net/note/edit/99702 Del: integrated -- https://master.php.net/note/delete/99702/integrated Del: useless -- https://master.php.net/note/delete/99702/useless Del: bad code -- https://master.php.net/note/delete/99702/bad+code Del: spam -- https://master.php.net/note/delete/99702/spam Del: non-english -- https://master.php.net/note/delete/99702/non-english Del: in docs -- https://master.php.net/note/delete/99702/in+docs Del: other reasons-- https://master.php.net/note/delete/99702 Reject -- https://master.php.net/note/reject/99702 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172207) next »