develooper Front page | perl.perl5.porters | Postings from June 2009

[perl #42329] Carp::croak() replace user error message by own

Thread Previous
From:
Bram via RT
Date:
June 28, 2009 14:40
Subject:
[perl #42329] Carp::croak() replace user error message by own
Message ID:
rt-3.6.HEAD-19080-1246197759-1466.42329-15-0@perl.org
On Wed Apr 30 03:52:52 2008, animator wrote:
> >
> > Looks like when script doing heavy I/O use all 1024 file 
descriptors,
> > fail on opening next one and try to report this error using 
croak(),
> > the Carp try to load (require) Carp::Heavy, and fail too (because
> >    there no
> > available file descriptors). This result in die() with message:
> >     Can't locate Carp/Heavy.pm in @INC (@INC contains: ...) at
> >     /usr/lib/perl5/5.8.8/Carp.pm line 255.
> > instead of original user's message.
> > 
> > I think Carp should avoid requesting more resources (memory, file
> > descriptors, etc.) when user call carp/croak/etc. Either 
Carp::Heavy
> > should be loaded together with Carp when script start or in case
> > Carp::Heavy can't be loaded Carp should contain some failback code,
> > which at least output user's message using usual warn/die.
> > 
> > -----------------------------------------------------------------
> 
> Patch attached that:
> a) shows the error from Carp::Heavy,
> b) the supplied string,
> c) a solution/work-around
> 
> 
> #!/usr/bin/perl -l
> 
> use Carp;
> my @t;
> for (1 .. 1024) {
>   open my $fh, "<", $0;
>   push @t, $fh;
> }
> croak "abc";
> __END__
> 
> Now shows:
> 
> Failed to load Carp::Heavy.  Consider adding use Carp::Heavy in your 
> code.
> Carp-Error: Can't locate Carp/Heavy.pm:   Too many open files at lib/
> Carp.pm line 44.
> Args: abc
> 

Any feedback on this? (patch is in RT)


Best regards,

Bram

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About