FAQ
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

Search Discussions

  • Wez Furlong at Jul 8, 2003 at 5:46 pm

    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 at Jul 8, 2003 at 5:58 pm
    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 at Jul 10, 2003 at 12:58 am
    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
    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 at Jul 10, 2003 at 4:23 am
    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
    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


    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedJul 8, '03 at 5:29p
activeJul 10, '03 at 4:23a
posts5
users5
websitephp.net

People

Translate

site design / logo © 2019 Grokbase