Subject: | callback (aka :content_cb) function hides basic typos and assorted runtime errors |
I'm not sure if this belongs in LWP::.*Protocol::http or in HTTP::Message or somewhere. I went source diving, but it appears to be beyond my skill level to find the eval{} or other capture.
Basically the problem is that this code will produce no errors, the rest of the callback will not fire, and the developer will be left wondering what the hell happened for like an hour and a half -- durations will vary.
$ua->get("blarg", ':content_cb' => sub { my $oops; $oops->broken_but_silent });
I attached a small demo of this, though, I think it was already pretty clear. Basically any runtime error (fatal typos die() croak() or other) will disappear into the æther. I tried this on a couple machines, but if it's unique to ubuntu, I wouldn't be super shocked. I've tried on 13.10 and 13.04, but I suspect it's really in the libwww-perl package somewhere and not related to cannonical perl patches.
--
If riding in an airplane is flying, then riding in a boat is swimming.
116 jumps, 48.6 minutes of freefall, 92.9 freefall miles.
Subject: | small.pl |
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my ($worked, $borked) = ("","");
# NOTE: clearly a bad typo in the second one... no error, no nuttin' :(
# broken in my LWP 6.05 perl5 (revision 5 version 14 subversion 2)
$ua->get("http://ip.kfr.me", ':content_cb' => sub { $worked .= shift });
$ua->get("http://ip.kfr.me", ':content_cb' => sub { my $o; $o->test; $borked .= shift });
print "worked: $worked";
print "borked: $borked\n";