in reply to Keeping Perl DBI Quiet

Many perl modules' routines die when something goes wrong.

DBI shouldn't unless you set RaiseError => 1 when you did your database handle connect.

The standard technique for dealing with such routines is:

eval { potentially_fatal_function_call(); } if ($@) { print "Fatal Error: $@"; # ... whatever other appropriate error recovery }

Wrapping the potentially fatal function call in an eval block means that if it dies, your program won't stop; it'll just set $@ and you can check it.

I recommend leaving RaiseError => 1 and trapping the errors yourself.

There's a current thread on formatting this idiom.

Replies are listed 'Best First'.
Re: Re: Keeping Perl DBI Quiet
by bart (Canon) on Nov 25, 2003 at 19:29 UTC
    In addition to RaiseError, the OP might want to take a look at PrintError. Usage is the same.