Re: exception handling in plperlu - Mailing list pgsql-general

From merlyn@stonehenge.com (Randal L. Schwartz)
Subject Re: exception handling in plperlu
Date
Msg-id 86odmtkwfg.fsf@blue.stonehenge.com
Whole thread Raw
In response to Re: exception handling in plperlu  (Douglas McNaught <doug@mcnaught.org>)
List pgsql-general
>>>>> "Douglas" == Douglas McNaught <doug@mcnaught.org> writes:

Douglas> my $dbh;

Douglas> eval { $dbh = connect(...) };

Since eval returns its value (or undef if $@ has the error), you can shorten
this to:

my $dbh = eval { DBI->connect(...) };

and now either look at $@ (if you want to distinguish exception vs normal) or
just defined $dbh (if you want to know if you have a useful handle or not).

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_dumpall and version confusion
Next
From: William Garrison
Date:
Subject: Bug in CREATE/DROP TABLESPACE command