I think the first item alone should cut down on a lot of the errors without causing much trouble. Now this doesn't address the larger problem of checking for db connections, but it should cut down on the number of errors users get and bug reports for when they do get errors.
This will also keep the process from dying which will help performance overall and I believe should return the message in the context of the site, which is nicer of course.
Any thoughts on this?
Patch is at http://emdee.net/ljlib.pl.diff