Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Net-Twitter CPAN distribution.

Report information
The Basics
Id: 43066
Status: resolved
Priority: 0/
Queue: Net-Twitter

People
Owner: cthom [...] cpan.org
Requestors: david [...] axiombox.com
Cc:
AdminCc:

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



Subject: get_error() doesn't return a hashref
Date: Thu, 5 Feb 2009 14:29:20 -0800
To: bug-Net-Twitter [...] rt.cpan.org
From: David Moreno <david [...] axiombox.com>
Download (untitled) / with headers
text/plain 826b
The documentation states the following for the get_error method: get_error If the last request returned an error, the hashref containing the error message can be retrieved with get_error. This will provide some additional debugging information in addition to the http code and message above. However, a string with the serialized json is returned instead. Take the following script to reproduce: #!/usr/bin/env perl use Net::Twitter 2.06; use Data::Dumper; my $t = Net::Twitter->new( username => 'something', password => 'fake', ); $t->update(status => "mwahah!"); if($t->get_error) { die Dumper $t->get_error; } Output: $VAR1 = '{"request":"\\/statuses\\/update.json","error":"Could not authenticate you."}'; Which is an scalar string, not a hash reference. David Moreno http://damog.net/
Download (untitled) / with headers
text/plain 946b
This seems to be a bug in the get_error() function. It makes no effort to convert the returned json string into an object. Here is a potential fix. Again, I have no idea how patches should be handled (or if anyone is actually maintaining this code?) but here's the diff. Maybe it can get rolled into the module? # diff -c ~/.cpan/build/Net-Twitter-2.06-GvP7LS/lib/Net/Twitter.pm ~/.cpan/build/Net- Twitter-2.06-GvP7LS\ /lib/Net/Twitter2.pm *** /Users/art/.cpan/build/Net-Twitter-2.06-GvP7LS/lib/Net/Twitter.pm 2009-02-11 10:52:18.000000000 -0800 --- /Users/art/.cpan/build/Net-Twitter-2.06-GvP7LS/lib/Net/Twitter2.pm 2009-02-11 10:54:30.000000000 -0800 *************** *** 131,137 **** sub get_error { my $self = shift; ! return $self->{response_error}; } sub http_code { --- 131,137 ---- sub get_error { my $self = shift; ! return JSON::Any->jsonToObj ($self->{response_error}); } sub http_code {
Download (untitled) / with headers
text/plain 393b
This came about because during 2.x development, $self->{response_error} contained an already decoded hashref. When I added the code in the various methods to eval and trap JSON decode errors, the get_error sub didn't follow. This is actually fixed in the copy on my local machine that will become 2.07. Work has prevented me from finishing it, but it should be available shortly. Thanks, -C


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.