On Jun 25, 2012, at 5:51 PM, Alvaro Herrera wrote:
>> However, that works only for the current lexical scope. If there are warnings in the code you are calling from the
currentscope, the use of `local $SIG{__WARN__}` is required.
>
> So lets add 'FATAL' to the already existing "use warnings" lines in
> Catalog.pm and genbki.pl.
>
> I think the other files we should add this to are generate-errcodes.pl,
> generate-plerrorcodes.pl, generate-spiexceptions.pl, Gen_fmgrtab.pl.
> Maybe psql/create_help.pl too.
>
> We have a bunch of files in ECPG and MSVC areas and others in src/tools;
> not sure about those.
>
> We also have gen_qsort_tuple.pl which amusingly does not even
> use warnings.
Hrm, I think that `use warnings 'FATAL';` might only work for core warnings. Which is annoying. I missed what was
warningup-thread, but the most foolproof way to make all warnings fatal is the originally suggested
local $SIG{__WARN__} = sub { die shift };
A *bit* cleaner is to use Carp::croak:
use Carp; local $SIG{__WARN__} = \&croak;
Or if you wanted to get a stack trace out of it, use Carp::confess:
use Carp; local $SIG{__WARN__} = \&confess;
Exception-handling in Perl is one of the few places that annoy me regularly.
Best,
David