|more useful options
Re: SQLite handling of errors through common functionby mje (Curate)
|on Nov 06, 2013 at 17:16 UTC
The first thing I'd point out is that if your connect worked but an error occurred later the arguments to the HandleError sub are 1. error string 2. the db handle being used when the fail occurred and 3. the first value returned by the failing method. Your HandleError sub seems to assume it is going to get a message/error string and a database name which it is ONLY going to get IF you call it like on line 23 of your example and not IF DBI calls it.
The second thing to point out is that if you have not connected then there is no connection handle passed to HandleError so the 2nd argument will be a DBI::dr, instead. e.g.,
Lastly, you are calling your own handle_error if connect fails so at that point you already know the connect failed. Your lines 18 to 23 will end in handle_error being called twice if connect fails.