Subject: | Better feedback on error conditions. |
I was installing WWW::Shorten today and a test failed. I suspected it was due to a service outage but there was no way to tell what was going wrong.
It would be nice if there were some sort of error feedback other than getting back 'undef' .
Test output was as follows:
--------------------------------------
t/00load.t .......... ok
t/00load_a.t ........ ok
t/00load_b.t ........ ok
t/00noexp.t ......... ok
t/00sig.t ........... ok
Show quoted text
# LWP::UserAgent 6.04
t/98pod-coverage.t .. ok
t/99pod.t ........... ok
t/linktoolbot.t ..... ok
t/linkz.t ........... ok
t/masl.t ............ ok
t/metamark.t ........ ok
t/newnames.t ........ ok
t/tinyclick.t ....... ok
t/tinylink.t ........ ok
Use of uninitialized value $return in pattern match (m//) at t/tinyurl.t line 7.
Use of uninitialized value $code in concatenation (.) or string at t/tinyurl.t line 9.
Show quoted text
# at t/tinyurl.t line 9.
# got: undef
# expected: 'http://tinyurl.com/'
Show quoted text
# at t/tinyurl.t line 10.
# got: undef
# expected: 'http://search.cpan.org/dist/WWW-Shorten/'
Show quoted text
# Looks like you failed 2 tests of 3 run.
# Looks like your test exited with 255 just after 3.
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 5/6 subtests
Test Summary Report
-------------------
t/tinyurl.t (Wstat: 65280 Tests: 3 Failed: 2)
Failed tests: 2-3
Non-zero exit status: 255
Parse errors: Bad plan. You planned 6 tests but ran 3.
--------------------------------------
So I ripped the code to shreds so I could see what was going on, and yep, as I suspected, the service itself was reporting unavailable.
perl /tmp/tiny.pl
Use of uninitialized value $v in concatenation (.) or string at /tmp/tiny.pl line 23.
do {
my $a = bless({
_content => "ERROR",
_headers => bless({
"client-date" => "Thu, 01 Mar 2012 04:12:32 GMT",
"client-peer" => "64.62.243.89:80",
"client-response-num" => 1,
"client-transfer-encoding" => ["chunked"],
"connection" => "close",
"content-type" => "text/html",
"date" => "Thu, 01 Mar 2012 04:12:32 GMT",
"server" => "TinyURL/1.6",
"x-powered-by" => "PHP/5.3.8",
}, "HTTP::Headers"),
_msg => "Service Not Available",
_protocol => "HTTP/1.1",
_rc => 503,
_request => bless({
_content => "url=http%3A%2F%2Fduckduckgo.com&source=PerlAPI-0.01",
_headers => bless({
"content-length" => 51,
"content-type" => "application/x-www-form-urlencoded",
"user-agent" => "main/",
}, "HTTP::Headers"),
_method => "POST",
_uri => bless(do{\(my $o = "http://tinyurl.com/api-create.php")}, "URI::http"),
_uri_canonical => 'fix',
}, "HTTP::Request"),
}, "HTTP::Response");
$a->{_request}{_uri_canonical} = \${$a->{_request}{_uri}};
$a;
} at /tmp/tiny.pl line 41.
Attached is the script I generated based on the TinyURL shortener to get this diagnosis if it proves helpful.
Thanks.
-- Kent
Subject: | tiny.pl |