exceptions question

php.internals

Greg Beaver

23 years ago
Hi, In experimenting with exceptions, I notice that throw() always jumps to the first catch() (as expected), and there is no way to return to the line after the throw(). Are we forced to use trigger_error() or some custom function for this kind of exception, or is there a way to tell PHP 5 "go back, the exception is fixed"? Thanks, Greg

Wez Furlong

23 years ago
> In experimenting with exceptions, I notice that throw() always jumps to > the first catch() (as expected), and there is no way to return to the > line after the throw().
That is precisely how exceptions are supposed to work.
> Are we forced to use trigger_error() or some > custom function for this kind of exception,
trigger_error() != exception.
> or is there a way to tell > PHP 5 "go back, the exception is fixed"?
Nope. You need to use separate try/catch blocks if you need more granularity. try { try { do_something(); } catch (exception $e) { // ignore it } do_something_else(); } catch (exception $e) { var_dump($e); } --Wez.

George Schlossnagle

23 years ago
That's not the way exceptions work in any language I know. On Tuesday, July 8, 2003, at 01:29 PM, Greg Beaver wrote:
> Hi, > > In experimenting with exceptions, I notice that throw() always jumps > to the first catch() (as expected), and there is no way to return to > the line after the throw(). Are we forced to use trigger_error() or > some custom function for this kind of exception, or is there a way to > tell PHP 5 "go back, the exception is fixed"? > > Thanks, > Greg > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
-- George Schlossnagle -- Principal Consultant -- OmniTI Computer Consulting, Inc. -- +1.410.872.4910 x202 -- 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0

Juan C. Rivera

23 years ago
You should not use exceptions for program logic. Exceptions are use to handle exceptional cases and the overhead of handling an exception may be quite expensive. At least on other languages. So, what is the overhead of throwing exceptions in PHP? Is it as expensive as in .Net or C++? -----Original Message----- From: Greg Beaver [mailto:greg@chiaraquartet.net] Sent: Tuesday, July 08, 2003 1:30 PM To: internals@lists.php.net Subject: [PHP-DEV] exceptions question Hi, In experimenting with exceptions, I notice that throw() always jumps to the first catch() (as expected), and there is no way to return to the line after the throw(). Are we forced to use trigger_error() or some custom function for this kind of exception, or is there a way to tell PHP 5 "go back, the exception is fixed"? Thanks, Greg
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Andi Gutmans

23 years ago
Yes, it is expensive. Andi At 08:57 PM 9/7/2003 -0400, Juan C. Rivera wrote: