Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:9113 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27988 invoked by uid 1010); 13 Apr 2004 19:22:50 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 27908 invoked from network); 13 Apr 2004 19:22:50 -0000 Received: from unknown (HELO shiva.mind.de) (212.42.230.204) by pb1.pair.com with SMTP; 13 Apr 2004 19:22:49 -0000 Received: from [192.168.1.105] (p508EA51A.dip.t-dialin.net [80.142.165.26]) by shiva.mind.de (Postfix) with ESMTP id A544597B4F; Tue, 13 Apr 2004 21:22:48 +0200 (CEST) Date: Tue, 13 Apr 2004 21:23:08 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <111605431609.20040413212308@marcus-boerger.de> To: Wez Furlong Cc: Adam Maccabee Trachtenberg , PHP Internals In-Reply-To: <00a801c420d5$9059e5b0$8a02a8c0@tron> References: <1081740243.14476.11.camel@coogle.localdomain> <00a801c420d5$9059e5b0$8a02a8c0@tron> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Exceptions and Errors From: helly@php.net (Marcus Boerger) Hello Wez, SQLite only throws exceptions from constructors. This is necessary to get the "constructor failed" information. It works using the support functions from main/main.c/main/php.h: typedef enum { EH_NORMAL = 0, EH_SUPPRESS, EH_THROW } error_handling_t; PHPAPI void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC); #define php_std_error_handling() php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC) php_set_error_handling(() sets the mode and class_entry. php_std_error_handling() resets the mode and class entry. EH_NORMAL => Standard behavior = no exceptions EH_SUPPRESS => Neither throw an exception nor show/log the error EH_THROW => Throw an exception if no excpetion is pending If exception_class == NULL then a standard exception will be generated. Monday, April 12, 2004, 11:31:46 PM, you wrote: > Note that sqlite does have an option to raise exceptions instead of errors. > I haven't tried this myself; Marcus will be able to advise more on how this > works. > --Wez. >> try { >> $db = new SQLiteDatabase('foo.db'); >> if ($db->query($sql)) { >> // fetch rows >> } else { >> // handle error >> } >> } catch { >> // handle exception >> } >> >> It's really crazy to need to mix both types of error handling within >> the same block of code. -- Best regards, Marcus mailto:helly@php.net