I got into a habit on my programs of doing something like this:
<code>
$sth = $dbh->prepare($sql);
if (! $sth->execute) {
$sth->finish;
&error_out('sql',0);
}
.... now $sth->fetchrow without worries
sub error_out {
my ($ctgy, $num) = @_;
$error_msgs = { 'sql' => [q!Failed to Execute SQL!,q!blah blah blah!],
'auth' => [q!Bad User/Pass!],
};
.... display error header, message, footer, mailto's .. etc.. then exit properly
</code>
With a nice neat anon-hash-of-arrays, it's easy to error out gracefully in the browser window. I just got really sick of my default Apache 500 error..
<h3>So - in english: Replace 500 Server errors with HTML ones..</h3>