Re: phpbuilder - Error Handling

From: Date: Tue, 18 Jul 2000 21:38:40 +0000
Subject: Re: phpbuilder - Error Handling
References: 1 2 3  Groups: php.pear 
Request: Send a blank email to php-pear+get-148@lists.php.net to get a copy of this message
> > > Sterling Hughes wrote: > > > > > > > Ulf Wendel wrote: > > > How do I "catch" an error? > > > > > > $ok = DB::connect(); > > > if ( is_object($ok) && "Exception" == substr(get_classname($ok), > > > ??end > > > of beginning?? ) ) { > > > $msg = $ok->getLocalizedMessage(); > > > # $ok->printLocalizedMessage(); > > > } > > > > > > > Easier yet, have DB:: (or whatever class) provide a method that checks > > whether or not it is an error object (we have something like that now): > > > > $ok = DB::connect(..); > > if (DB::isError ($ok)) { > > /* .. */ > > } > > Forgot that and I buy that. isError() could do the above (or a similar) > if statement. You're voting for the way to use an error object instead > of integer constants, don't you? > Yes. I'm for the object approach. -Sterling

« previous php.pear (#148) next »