Re: Re: cvs: php4 /pear/Crypt CBC.php
| From: | Tomas V.V.Cox | Date: | Tue, 24 Apr 2001 01:39:11 +0000 |
| Subject: | Re: Re: cvs: php4 /pear/Crypt CBC.php | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-297@lists.php.net to get a copy of this message | ||
Colin Viebrock wrote:
>
> > Since you inherit PEAR, it is better to use $this->raiseError(). That
> > way the user can set default error handling in the Crypt_CBC object.
>
> Thanks ... I just changed it. :)
>
> However, even on an error, the constructor doesn't return a Pear_Error
> object (or Crypt_CBC_Error object).
In a very cursory review I see in your code:
return $this->raiseError('no initialization vector', null,
PEAR_ERROR_PRINT, null, null, 'Crypt_CBC_Error', false
);
If you use PRINT as default error mode, you'll never get a object back.
PEAR_ERROR_RETURN is for that.
> I don't need to do something like this, do I?
>
> if (something bad) {
> $this = PEAR::raiseError(...)
> return $this;
> }
>
> How can you get the constructor of a class to "construct" a class of some
> other kind?
In the constructor of your class you need to do a:
$this->PEAR($your_error_class) (or null for PEAR_Errors) call. It will
set the error class of error objs. Then you can raise errors so:
return $this->raiseError ($message, $code, null, null, $debug, null,
null);
Hope I'm not wrong with the question or the answer :)
Tomas V.V.Cox