Michael Bell wrote:
>
> Massimiliano Pala wrote:
> >
> > Michael Bell wrote:
> > > What is the returned value of a failing function? I would recommend
> > > undef for all functions so we have a clear design decision and we could
> > > cleanup a lot of functions which directly return negative errorcodes.
> >
> > Since now I have set:
> >
> > return
> >
> > for errors and:
> >
> > return 1 <--- or $ret val (not null)
> >
> > for successful return value. The errno should be set to "0" if everything
> > has run fine while a value > 0 if some errors occurred. It would be not
> > bad having some errors strings defined within the modules and having the
> > error numbers coherent with different modules (so having a set of common
> > error codes and some module specific error codes). I think this will require
> > SOME EXTRA work... again... :-(
>
> I use the following:
> failed:
> -------
> return undef and set errno (works for a failing new() too if you are
> using OpenCA::DBI->errno() directly :-D)
This can work althought it should not be raccomended accessing directly
object's value... :-D The undef value is ok so we can use check like:
if ( not $obj->sub() ) {
error!;
} else {
ok!;
}
or the like.
> success:
> --------
> return a defined value and set errno - the errno must not be 0 because
> there could be errors which I can recover. E.g. if the first
> databaseaccess fails it is possible to set an option second_chance and
> then I try it twice but of cause there was an error.
If the operation have success and returns a true value you can have errno
as you wish, this should not be a problem, I guess. You can also have, if
you need to, an internal errno ( let's call it int_errno ) and use it
for internal error checking (or status recovery).
--
C'you,
Massimiliano Pala
--o-------------------------------------------------------------------------
Massimiliano Pala [OpenCA Project Manager] [EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.openca.org Tel.: +39 (0)59 270 094
http://openca.sourceforge.net Mobile: +39 (0)347 7222 365
S/MIME Cryptographic Signature