Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8992 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15620 invoked by uid 1010); 8 Apr 2004 11:04:45 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 15581 invoked from network); 8 Apr 2004 11:04:45 -0000 Received: from unknown (HELO smtprelay01.ispgateway.de) (62.67.200.156) by pb1.pair.com with SMTP; 8 Apr 2004 11:04:45 -0000 Received: (qmail 10789 invoked from network); 8 Apr 2004 11:04:44 -0000 Received: from unknown (HELO heinz-ruediger) (126482@[212.202.104.234]) (envelope-sender ) by smtprelay01.ispgateway.de (qmail-ldap-1.03) with SMTP for ; 8 Apr 2004 11:04:44 -0000 To: internals@lists.php.net Date: Thu, 08 Apr 2004 13:05:36 +0200 MIME-Version: 1.0 Message-ID: <40754E20.1547.20CA6A@localhost> Priority: normal In-reply-to: References: <20040408101703.53487.qmail@pb1.pair.com> X-mailer: Pegasus Mail for Windows (v4.12a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Subject: Re: [PHP-DEV] Exceptions and builtin functions in PHP5 From: fb@fbeyer.com ("Ferdinand Beyer") On 8 Apr 2004 at 12:45, Derick Rethans wrote: > > I want to write: > > ... > > $res = some_builtin_func(); // func raises exception on error > > // so I don't need to write additional lines > > ... > > > > So will PHP5 (or future versions) work as in my 2nd example? > > No It would be a nice feature to let the user decide whether to throw exceptions when errors are triggered: // either ERROR_TRIGGER or ERROR_EXCEPTION error_handling(ERROR_EXCEPTION); // Don't throw exceptions for notices or warnings error_reporting(E_ERROR); try { mysql_connect() } catch (Notice $e) { echo 'Notice: ' . $e->getMessage(); } catch (Warning $e) { echo 'Warning: ' . $e->getMessage(); } catch (Error $e) { echo 'Error: ' . $e->getMessage(); } catch (Exception $e) { echo 'Unknown exception: ' . $e->getMessage(); } -- Ferdinand Beyer