note 77516 added to language.exceptions

From: Date: Sat, 01 Sep 2007 22:33:56 +0000
Subject: note 77516 added to language.exceptions
Groups: php.notes 
Request: Send a blank email to php-notes+get-130078@lists.php.net to get a copy of this message
Note that throw is a language construct (see http://php.net/manual/en/reserved.php) not a function, which prevents you from using compact expressions such as: <?php function inverse($v) { is_numeric($v) or throw new BadArgumentException(); // ... snip } ?> So, you can emulate it with a little wrapper: <?php function toss($e) { throw $e; } function inverse($v) { is_numeric($v) or toss(new BadArgumentException()); // ... snip } ?> Because the Exception is instantiated in the same place, the stack trace inside the exception is the same. http://bytejar.com/ - Software Lessons Learned the Hard Way ---- Server IP: 69.147.83.197 Probable Submitter: 24.148.133.105 ---- Manual Page -- http://www.php.net/manual/en/language.exceptions.php Edit -- https://master.php.net/note/edit/77516 Del: integrated -- https://master.php.net/note/delete/77516/integrated Del: useless -- https://master.php.net/note/delete/77516/useless Del: bad code -- https://master.php.net/note/delete/77516/bad+code Del: spam -- https://master.php.net/note/delete/77516/spam Del: non-english -- https://master.php.net/note/delete/77516/non-english Del: in docs -- https://master.php.net/note/delete/77516/in+docs Del: other reasons-- https://master.php.net/note/delete/77516 Reject -- https://master.php.net/note/reject/77516 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130078) next »