Re: Re: cvs: php4 /pear/Crypt CBC.php
| From: | Colin Viebrock | Date: | Tue, 24 Apr 2001 14:47:53 +0000 |
| Subject: | Re: Re: cvs: php4 /pear/Crypt CBC.php | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-308@lists.php.net to get a copy of this message | ||
> Colin, in general it's not a good idea to pass mode in raiseError,
> because it takes control away from the user. If I have a callback
> function that I want to use for all error handling, it will never be
> called when you override my default mode in the raiseError call.
Fair enough. :)
> If you call the PEAR constructor with 'Crypt_CBC_Error' as the first
> parameter (or no parameter, you don't really need to override
> PEAR_Error unless you really want a different prefix), you only need
> to specify the error message in your raiseError call:
>
> function Crypt_CBC(...)
> {
> $this->PEAR();
> }
> ...
> return $this->raiseError('no initialization vector');
Okay I changed my code to something like this:
function Crypt_CBC($key, $cipher)
{
$this->PEAR();
if (!$key) {
return $this->raiseError('no key');
}
...
}
But when, I run it:
$c = new Crypt_CBC('', 'des');
$c is not a PEAR_Error object. That's what I'm trying to do. :)
> > > I don't need to do something like this, do I?
> > >
> > > if (something bad) {
> > > $this = PEAR::raiseError(...)
> > > return $this;
> > > }
>
> Overwriting the $this variable is not a good idea. :-)
Agreed. :) However, this seems to be the only way to get the Crypt_CBC
constructor to not create a Crypt_CBC object.
Sorry if I'm being difficult. :)
- Colin
P.S. When will someone fix the "list-post:" header for the DEV and CVS
lists? Or is that something generated by the news.php.net NNTP server? I'm
still trying to filter Tomas' emails properly. :)