Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Catching GD warning

by Marcello (Hermit)
on May 03, 2006 at 14:59 UTC ( #547168=note: print w/replies, xml ) Need Help??


in reply to Re: Catching GD warning
in thread Catching GD warning

Well actually no, I already tried that:
use strict; use warnings; use GD; $SIG{__WARN__} = sub { print "Caught warning: ".$_[0] }; my $image; eval { ($image = GD::Image->new("test.jpg")) or warn "Error: ".$!; }; if ($@) { print "Caught ".$@; } if (defined($image)) { print "Image is defined: ".$image."\n"; }
produces:
Corrupt JPEG data: 104 extraneous bytes before marker 0xd9 Image is defined: GD::Image=SCALAR(0x817eba4)
What am I missing?

Replies are listed 'Best First'.
Re^3: Catching GD warning
by wazoox (Prior) on May 03, 2006 at 15:19 UTC

    Looks like a bug to me. If GD::Image is sending something to STDERR (like it seems to) then it should be manageable thru $SIG{__WARN__}. Try redirecting the STDERR and see what's happenning.

    Update: Looks like actually XS Module stderr can't be easily catched, there's even a module for that: IO::CaptureOutput, hence that should provide you with the solution to your problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://547168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2020-05-27 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (152 votes). Check out past polls.

    Notices?