Subject: | error handling |
Date: | Sun, 30 Nov 2008 18:59:19 -0500 |
To: | bug-webservice-linode [...] rt.cpan.org |
From: | Pat Hennessy <pat [...] pathennessy.com> |
I ran into an issue where I did not have Crypt:SSLeay installed and the
only error I got was "No JSON found". I saw it was originating from the
parse_response function, so I threw in a print statement and found out
what the problem was. It might be better to print the
$response->content if it doesn't contain valid JSON so someone can see
what other errors are return from LWP.
The attached patch works, but there may be a cleaner way to check. Like
maybe just putting "use Crypt:SSLeay;" at the top of the module. On my
Ubuntu 8.04 system, it outputs..
$ ./test.pl
No JSON found
ERROR: LWP will support https URLs if the Crypt::SSLeay module is installed.
More information at <http://www.linpro.no/lwp/libwww-perl/README.SSL>.
at ./test.pl line 17
Can't use an undefined value as an ARRAY reference at ./test.pl line 17.
diff -ru WebService-Linode-0.02.orig/lib/WebService/Linode.pm WebService-Linode-0.02/lib/WebService/Linode.pm
--- WebService-Linode-0.02.orig/lib/WebService/Linode.pm 2008-09-15 20:31:58.000000000 -0400
+++ WebService-Linode-0.02/lib/WebService/Linode.pm 2008-11-30 18:54:56.000000000 -0500
@@ -85,6 +85,9 @@
);
return;
}
+ } elsif ($response->content) {
+ $self->_error(-1, "No JSON found\nERROR: " . $response->content);
+ return;
} else {
$self->_error(-1, 'No JSON found');
return;