File Coverage

blib/lib/OAuth/Lite2/Client/Error.pm
Criterion Covered Total %
statement 9 20 45.0
branch n/a
condition 0 3 0.0
subroutine 3 11 27.2
pod 0 4 0.0
total 12 38 31.5


line stmt bran cond sub pod time code
1             package OAuth::Lite2::Client::Error;
2              
3 1     1   3 use strict;
  1         2  
  1         21  
4 1     1   3 use warnings;
  1         1  
  1         36  
5              
6             use overload
7 0     0     q{""} => sub { shift->message },
8 1     1   4 fallback => 1;
  1         1  
  1         9  
9              
10 0     0 0   sub default_message { "error" }
11              
12             sub new {
13 0     0 0   my ($class, %args) = @_;
14             bless {
15 0   0       message => $args{message} || $class->default_message,
16             }, $class;
17             }
18              
19             sub throw {
20 0     0 0   my ($class, %args) = @_;
21 0           die $class->new(%args);
22             }
23              
24             sub message {
25 0     0 0   my $self = shift;
26 0           return $self->{message};
27             }
28              
29             package OAuth::Lite2::Client::Error::InvalidResponse;
30             our @ISA = qw(OAuth::Lite2::Client::Error);
31 0     0     sub default_message { "invalid response" }
32              
33             package OAuth::Lite2::Client::Error::InsecureRequest;
34             our @ISA = qw(OAuth::Lite2::Client::Error);
35 0     0     sub default_message { "insecure request" }
36              
37             package OAuth::Lite2::Client::Error::InsecureResponse;
38             our @ISA = qw(OAuth::Lite2::Client::Error);
39 0     0     sub default_message { "insecure response" }
40              
41             package OAuth::Lite2::Client::Error;
42              
43             =head1 NAME
44              
45             OAuth::Lite2::Client::Error - OAuth 2.0 client error
46              
47             =head1 SYNOPSIS
48              
49             OAuth::Lite2::Client::Error::InvalidResponse->throw(
50             message => q{invalid format},
51             );
52              
53             =head1 DESCRIPTION
54              
55             OAuth 2.0 client error
56              
57             =head1 ERRORS
58              
59             =over 4
60              
61             =item OAuth::Lite2::Client::Error::InvalidResponse
62              
63             =item OAuth::Lite2::Client::Error::InsecureRequest
64              
65             =item OAuth::Lite2::Client::Error::InsecureResponse
66              
67             =back
68              
69             =head1 AUTHOR
70              
71             Lyo Kato, Elyo.kato@gmail.comE
72              
73             =head1 COPYRIGHT AND LICENSE
74              
75             Copyright (C) 2010 by Lyo Kato
76              
77             This library is free software; you can redistribute it and/or modify
78             it under the same terms as Perl itself, either Perl version 5.8.8 or,
79             at your option, any later version of Perl 5 you may have available.
80              
81             =cut
82              
83             1;