Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WebService-Linode CPAN distribution.

Report information
The Basics
Id: 41328
Status: resolved
Priority: 0/
Queue: WebService-Linode

People
Owner: michael [...] thegrebs.com
Requestors: pat [...] pathennessy.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.03



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;
Subject: Re: [rt.cpan.org #41328] AutoReply: error handling
Date: Sun, 30 Nov 2008 19:15:53 -0500
To: bug-WebService-Linode [...] rt.cpan.org
From: Pat Hennessy <pat [...] pathennessy.com>
I have attached an updated patch which I think uses the appropriate methods from LWP.
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 19:12:17.000000000 -0500 @@ -68,7 +68,7 @@ my $self = shift; my $response = shift; - if ($response->content =~ m|ERRORARRAY|i) { + if ($response->is_success && $response->content =~ m|ERRORARRAY|i) { my $json = from_json($response->content); if (scalar (@{$json->{ERRORARRAY}}) == 0) { return $json->{DATA}; @@ -85,6 +85,9 @@ ); return; } + } elsif ($response->status_line) { + $self->_error(-1, $response->status_line); + return; } else { $self->_error(-1, 'No JSON found'); return;
Thanks Pat, will get your patch as sent applied. Will probably add the necessary modules for SSL to the meta.yml for auto dependency resolution goodness as well.
0.03 is tagged in git and now making its way through CPAN with this patch slightly modified applied. http://git.thegrebs.com/?p=WebService-Linode;a=summary I left the initial if condition the same as the Linode side does respond with error codes for some API errors. This way if there is valid JSON from Linode, that error message is used, if not, we use the response objects status line, failing that, the old uninformative 'No JSON found'. In addition, I've added Crypt::SSLeay to the list of required modules in Makefile.PL with a note for those wishing to use IO::Socket::SSL in the README. Thank you for taking the time both to report the issue and submit a patch.