File Coverage

blib/lib/WWW/Shorten/UserAgent.pm
Criterion Covered Total %
statement 9 17 52.9
branch 0 4 0.0
condition n/a
subroutine 3 5 60.0
pod 2 2 100.0
total 14 28 50.0


line stmt bran cond sub pod time code
1             package WWW::Shorten::UserAgent;
2              
3 7     7   23 use strict;
  7         8  
  7         156  
4 7     7   22 use warnings;
  7         7  
  7         181  
5              
6 7     7   21 use base 'LWP::UserAgent';
  7         6  
  7         4201  
7              
8             our $VERSION = '3.093';
9             $VERSION = eval $VERSION;
10              
11             sub get {
12 0     0 1   my $self = shift;
13 0           my $resp = $self->SUPER::get(@_);
14              
15 0 0         die $resp->status_line if $resp->is_error;
16              
17 0           return $resp;
18             }
19              
20             sub post {
21 0     0 1   my $self = shift;
22 0           my $resp = $self->SUPER::post(@_);
23              
24 0 0         die $resp->status_line if $resp->is_error;
25              
26 0           return $resp;
27             }
28              
29             1;
30              
31             =head1 NAME
32              
33             WWW::Shorten::UserAgent - LWP::UserAgent subclass for WWW::Shorten modules.
34              
35             =head1 SYNOPSIS
36              
37             use strict;
38             use warnings;
39             use WWW::Shorten::UserAgent;
40             use Try::Tiny qw(try catch);
41              
42             my $ua = WWW::Shorten::UserAgent->new;
43              
44             my $resp = try {
45             $ua->get($url);
46             }
47             catch {
48             warn "Uh oh: $_";
49             return undef;
50             };
51              
52             =head1 DESCRIPTION
53              
54             Subclass of LWP::UserAgent which works the same way as the superclass
55             except that it throws an exception if the C or C method returns
56             an error.
57              
58             See L for the full documentation.
59              
60             =head1 METHODS
61              
62             =head2 get
63              
64             Makes an HTTP GET request and throws an exception on error.
65              
66             =head2 post
67              
68             Makes an HTTP POST request and throws an exception on error.
69              
70             =head1 AUTHOR
71              
72             Dave Cross
73              
74             =head1 LICENSE AND COPYRIGHT
75              
76             Copyright (c) Magnum Solutions Ltd., 2012. All rights reserved.
77              
78             This module is free software. You can redistribute it and/or
79             modify it under the terms of the Artistic License 2.0.
80              
81             This program is distributed in the hope that it will be useful,
82             but without any warranty; without even the implied warranty of
83             merchantability or fitness for a particular purpose.
84              
85             =head1 SEE ALSO
86              
87             L
88              
89             =cut