RE: Documentation / Error checking



Thanks Tim.

> I'll clarify the docs. Basically all methods calls reset err except for
> just a few special cases such as err and errstr, obviously, and FETCH
> eg $foo = $h->{SomeAttribute}).

>From the first part of your answer I understand that's it's always okay to
test for "defined DBI::err" (if I want to die on warnings) or "DBI::err" if
I am willing to live with warnings and would like to die on errors only. Is
that correct?

> Well, if you're going to die() I'd just set RaiseError and forget about
it.
> If there's some good reason you don't want to use RaiseError then this
would do:

Of course when I write "die" I don't really mean die, I have error handling
code which does quite a bit. It's just a shorthand for writing. Otherwise I
would use RaiseError as you suggest.

> my $hr = $dbh->selectrow_hashref( ... ) or die(...);

.... but from your first part of your answer I may also do:
my $hr = $dbh->selectrow_hashref( ... );
defined $DBI::err and do_special_error_handling_code();

.... correct?

Thanks again,
Nitzan

.



Relevant Pages

  • Re: Documentation / Error checking
    ... Basically all methods calls reset err except for ... This is a fuzzy area of the DBI and I'm not guaranteeing that this list ... > selectall_arrayrefand selectcol_arrayrefhave similar documentation. ... if you're going to dieI'd just set RaiseError and forget about it. ...
    (perl.dbi.users)
  • Re: ShowErrorStatement
    ... ShowErrorStatement just adds information to the message produced by ... RaiseError and PrintError. ... I recommend ShowErrorStatement. ... I don't recommend "or die ...", ...
    (perl.dbi.users)
  • Re: DBI->connect fails with perl 5.8?
    ... This may be a red herring but for what it's worth we always give the SID ... in the DSN, like: ... RaiseError => 1}) or die... ...
    (comp.lang.perl.misc)
  • Re: Is it correct that execute_array does not raise/print an error
    ... If RaiseError caused a die on error and someone wanted to ignore errors ... when RaiseError was enabled was by design or a an oversight. ... which execute_arrayarray calls to do the real work. ...
    (perl.dbi.users)