develooper Front page | perl.dbi.dev | Postings from January 2019

Re: RaiseWarn attribute for DBI

Thread Previous | Thread Next
From:
pali
Date:
January 19, 2019 11:34
Subject:
Re: RaiseWarn attribute for DBI
Message ID:
20190119113435.g3xe75swdbuf4sl2@pali
In my proposed implementation is HandleError called also for warnings
when RaiseWarn is enabled -- so for everything which is (later) going to
be passed to DBI's die. And based on return value of HandleError
callback, die/exception can be either silenced or re-throw like for DBI
errors.

Collecting all DBI warnings and storing them into special/custom log
looks like a good thing to do.

On Friday 18 January 2019 11:01:31 Dan Book wrote:
> As a side note, I have in the past thought a HandleWarn option may be
> useful, for instance to log warnings from the database or other custom
> behavior. It could also be used to throw exceptions.
> 
> -Dan
> 
> On Thu, Jan 17, 2019 at 4:03 AM <pali@cpan.org> wrote:
> 
> > Hello!
> >
> > What do you think about adding a new attribute $dbh->{RaiseWarn} which
> > cause that warnings reported by DBI drivers would behave like errors?
> >
> > For errors DBI has there $dbh->{PrintError} and $dbh->{RaiseError}
> > attributes. First one is by default true and second one by default
> > false. When PrintWarn is true, then all error from DBI driver are passed
> > to perl's "warn" function and when RaiseError is true, then errors are
> > passed to perl's "die" function. (Plus there is ability to register own
> > error handler function)
> >
> > Currently DBI has only $dbh->{PrintWarn} attribute to control warnings.
> > When is set to true (by default) all warnings from DBI driver are passed
> > to perl's "warn" function.
> >
> > So I would propose to add $dbh->{RaiseWarn} attribute (off by default)
> > to behave like $dbh->{RaiseError}, but for warnings.
> >
> > I have implemented this attribute and patch is there:
> > https://github.com/perl5-dbi/dbi/pull/71/files
> >

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About