in reply to Re: Problem of scope : $SIG{__WARN__} in a module...
in thread Problem of scope : $SIG{__WARN__} in a module...

you can give the DBI handle an error handler:

$h->{RaiseError} = 1; # Turn all warnings into dies
$h->{HandleError} = sub { set_dberror(join('',@_)) };

Any errors generated by the dbh will be passed to your sub.
Errr... I don't really get it, how is this code supposed to work? won't it pass any warning to the sub, not only the dbh warnings ?
  • Comment on Re^2: Problem of scope : $SIG{__WARN__} in a module...

Replies are listed 'Best First'.
Re^3: Problem of scope : $SIG{__WARN__} in a module...
by TedYoung (Deacon) on Dec 03, 2004 at 19:25 UTC
    Nope, this code will pass only DBH warnings to the set_dberror sub. You do it when when you initialize your DBH handle. Although, I don't think it handles connnection errors.

    Ted Young

    ($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)

      Ok, I got it now. It's OK for me, it'll do the trick. I just want my script to report neatly all errors when exiting, I don't mind seeing all sort of warnings mixing up with the stdout...

      Thanks all :)