Re: Exceptions and Errors

From: Date: Tue, 13 Apr 2004 23:12:40 +0000
Subject: Re: Exceptions and Errors
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  Groups: php.internals 
Request: Send a blank email to internals+get-9134@lists.php.net to get a copy of this message
Hello Adam, Wednesday, April 14, 2004, 12:58:36 AM, you wrote: > On Wed, 14 Apr 2004, Marcus Boerger wrote: >> > If the developer catches it, they handle it. If they don't, PHP >> > catches it and issues a fatal error. >> >> I am not a friend of PHP catching exceptions and converting them to >> E_ERRORs. Just have an uncaught exception message as we have now. >> And no way of generous catching E_ERRORs by back-door. > This is what I meant. An uncaught exception message is fatal right > now. > PHP Fatal error: Uncaught exception 'SQLiteException' with message > 'SQLiteDatabase::__construct(): unable to open database: /sbin/foo' > in Command line code:1 > Stack trace: > #0 {main} > thrown in Command line code on line 1 > This is actually a pretty nasty side effect of throwing exceptions in > ctors because these two lines have *very* different results if they > fail: > $db = new SQLiteDatabase(); > $db = sqlite_open(); sqlite_open returns a resource and new SQLiteDatabase returns an object. The latter is a ctor and to prevent it throwing exceptions you'd need to provide a factory method, make the ctor private (which prevents inhering) and then look ofr all possible kinds of failures before calling the ctor. -- Best regards, Marcus mailto:helly@php.net

« previous php.internals (#9134) next »