Re: PEAR error handling question

From: Date: Mon, 27 Jan 2003 01:04:40 +0000
Subject: Re: PEAR error handling question
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-12764@lists.php.net to get a copy of this message
--- Michael Bretterklieber <mbretter@jawa.at> wrote: > Hi, > > is something like this allowed, or is the only allowed way to handle > errors: http://pear.php.net/manual/en/class.pear.php: In principle it should be OK. Just that doing: class Bla { function &foo() { ... if ($success) { return true; } else { return PEAR::raiseError($errmsg); } } } allows you to use that as a static method call, e.g: you can do: $foo = new Bla(); $res =& $foo->foo(); if (PEAR::isError($res) { ... } or: $res =& Bla::foo(); if (PEAR::isError($res) { return $res; } > > class Bla extends PEAR { > var $pear_error; > > function foo() > { > ... > if ($success) { > return true; > } else { > $this->pear_error = $this->raiseError('error 99 change user'); > return false; > > } > } > } > > $blo = new Bla; > if (!$blo->foo()) { > echo $blo->pear_error->getMessage(); > } > > bye, > -- > ------------------------------- ------------------------------------- > Michael Bretterklieber - Michael.Bretterklieber@jawa.at > JAWA Management Software GmbH - http://www.jawa.at > Liebenauer Hauptstr. 200 -------------- privat --------------- > A-8041 GRAZ GSM: ++43-(0)676-93 96 698 > Tel: ++43-(0)316-403274-12 E-mail: michael@bretterklieber.com > Fax: ++43-(0)316-403274-10 http://www.bretterklieber.com > ------------------------------- ------------------------------------- > "...the number of UNIX installations has grown to 10, with more > expected..." - Dennis Ritchie and Ken Thompson, June 1972 > > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) Research: http://metallo.scripps.edu/ Personal: http://www.castagnetto.org/ __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com

« previous php.pear.dev (#12764) next »