| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Tumblr::ResponseError; |
|
2
|
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
62
|
use Moose; |
|
|
16
|
|
|
|
|
30
|
|
|
|
16
|
|
|
|
|
77
|
|
|
4
|
16
|
|
|
16
|
|
69952
|
use Data::Dumper; |
|
|
16
|
|
|
|
|
25
|
|
|
|
16
|
|
|
|
|
903
|
|
|
5
|
16
|
|
|
16
|
|
57
|
use JSON 'decode_json'; |
|
|
16
|
|
|
|
|
25
|
|
|
|
16
|
|
|
|
|
89
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'response', is => 'rw', isa => 'HTTP::Response'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
0
|
|
|
0
|
1
|
|
sub code { $_[0]->response->code } |
|
10
|
|
|
|
|
|
|
sub reasons { |
|
11
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
|
12
|
0
|
|
|
|
|
|
my $j = decode_json( $_[0]->response->decoded_content); |
|
13
|
0
|
0
|
0
|
|
|
|
if ( ref $j && ref $j eq 'HASH' ) { |
|
14
|
0
|
0
|
0
|
|
|
|
if ( ref $j->{response} && ref $j->{response} eq 'ARRAY' ) { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
unless ( scalar @{ $j->{response} }) { |
|
|
0
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
return [ $self->response->message ] |
|
17
|
|
|
|
|
|
|
} |
|
18
|
0
|
|
|
|
|
|
return $j->{response}; |
|
19
|
|
|
|
|
|
|
} elsif ( ref $j->{response} && ref $j->{response} eq 'HASH' && |
|
20
|
|
|
|
|
|
|
defined $j->{response}->{errors} |
|
21
|
|
|
|
|
|
|
) { |
|
22
|
0
|
0
|
0
|
|
|
|
if ( ref $j->{response}->{errors} eq 'HASH' && |
|
|
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
defined $j->{response}->{errors}->{state} ) { |
|
24
|
|
|
|
|
|
|
return [ |
|
25
|
|
|
|
|
|
|
$j->{response}->{errors}->{0}, |
|
26
|
|
|
|
|
|
|
$j->{response}->{errors}->{state} |
|
27
|
0
|
|
|
|
|
|
]; |
|
28
|
|
|
|
|
|
|
} elsif ( ref $j->{response}->{errors} eq 'ARRAY' ) { |
|
29
|
0
|
|
|
|
|
|
return $j->{response}->{errors}; |
|
30
|
|
|
|
|
|
|
} else { |
|
31
|
0
|
|
|
|
|
|
Carp::croak "Unimplemented"; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
} else { |
|
34
|
0
|
|
|
|
|
|
Carp::croak "Unimplemented"; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
} else { |
|
37
|
0
|
|
|
|
|
|
Carp::croak "Unimplemented"; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
WWW::Tumblr::ResponseError |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $posts = $tumblr->blog('stupidshit.tumblr.com')->posts; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
die "Couldn't get posts! " . Dumper( $tumblr->error->reasons ) unless $posts; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This a class representing L<WWW::Tumblr>'s C<error> method. It contains the |
|
58
|
|
|
|
|
|
|
response from upstream Tumblr API. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 error |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Callable from a model context, usually L<WWW::Tumblr>. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
print Dumper $tumblr->error unless $post; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 code |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
HTTP response code for the error: |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $info = $blog->info; |
|
73
|
|
|
|
|
|
|
print $blog->error->code . ' nono :(' unless $info; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 reasons |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Commodity method to display reasons why the error ocurred. It returns an array |
|
78
|
|
|
|
|
|
|
reference: |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
unless ( $some_tumblr_action ) { |
|
81
|
|
|
|
|
|
|
print "Errors! \n"; |
|
82
|
|
|
|
|
|
|
print $_, "\n" for @{ $tumblr->error->reasons || [] }; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 BUGS |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Please refer to L<WWW::Tumblr>. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR(S) |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The same folks as L<WWW::Tumblr>. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L<WWW::Tumblr>, L<WWW::Tumblr::ResponseError>. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT and LICENSE |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Same as L<WWW::Tumblr>. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
|
102
|
|
|
|
|
|
|
|