# exceptions question

- Thread: https://externals.io/message/3305
- Original archive: https://news-web.php.net/php.internals/3305
- Started by Greg Beaver on 2003-07-08T17:29:58+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #3305 — Greg Beaver — 2003-07-08T17:29:58+00:00

URL: https://externals.io/message/3305#3305

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

---

## #3306 — Wez Furlong — 2003-07-08T17:45:57+00:00

URL: https://externals.io/message/3305#3306 · In reply to: #3305

> 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.

---

## #3307 — George Schlossnagle — 2003-07-08T17:58:42+00:00

URL: https://externals.io/message/3305#3307 · In reply to: #3305

That's not the way exceptions work in any language I know.



> 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
>
>
> -- 
> 
> 
>
>
-- 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

---

## #3341 — Juan C. Rivera — 2003-07-10T00:57:32+00:00

URL: https://externals.io/message/3305#3341 · In reply to: #3305

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

---

## #3343 — Andi Gutmans — 2003-07-10T05:27:16+00:00

URL: https://externals.io/message/3305#3343 · In reply to: #3305

Yes, it is expensive.

Andi

At 08:57 PM 9/7/2003 -0400, Juan C. Rivera wrote:
>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
