[nycphp-talk] PHP 5 Throwing Exceptions in Constructors
Adam Maccabee Trachtenberg
adam at trachtenberg.com
Thu Feb 10 00:20:32 EST 2005
On Wed, 9 Feb 2005, Matthew Terenzio wrote:
> > Is it possible to gain some insulation in certain cases by using a
> > specific exception subclass object type?
>
> To clarify what I mean, I'm wondering if Hans can't add an additional
> catch like Example 20-3->example 1 below
> and somehow only abort the instantiation if a critical exception is
> thrown
It up to you to choose if you want to abort the
instantiation. However, if you want to return an error in a
constructor, you need to throw some form of exception. It can either
be the base Exception class, or a subclass, but you can't do something
like returning false.
-adam
--
adam at trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!
More information about the talk
mailing list
Automatic Email Organization without missing anything!