File Coverage

blib/lib/WWW/Yahoo/Groups/Errors.pm
Criterion Covered Total %
statement 4 4 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 6 100.0


line stmt bran cond sub pod time code
1             package WWW::Yahoo::Groups::Errors;
2             our $VERSION = '1.91';
3              
4             =head1 NAME
5              
6             WWW::Yahoo::Groups::Errors - Exception classes for WYG
7              
8             =head1 DESCRIPTION
9              
10             This class provides assorted exceptions for the use of the other
11             modules.
12              
13             =head1 INHERITANCE
14              
15             All errors are subclasses of C which is a
16             subclass of C. See L's
17             documentation for methods available on the errors.
18              
19             =head1 EXTRA METHODS
20              
21             Beyond what L provides, there are two extra methods.
22              
23             =head2 fatal
24              
25             C will return true if the error caught should be one that
26             terminates the process.
27              
28             =head1 AVAILABLE CLASSES
29              
30             These should be obvious from their name. If not, please consult the
31             source or use the C method.
32              
33             X::WWW::Yahoo::Groups::BadParam
34             X::WWW::Yahoo::Groups::BadLogin
35             X::WWW::Yahoo::Groups::NoHere
36             X::WWW::Yahoo::Groups::AlreadyLoggedIn
37             X::WWW::Yahoo::Groups::NotLoggedIn
38             X::WWW::Yahoo::Groups::NoListSet
39             X::WWW::Yahoo::Groups::UnexpectedPage
40             X::WWW::Yahoo::Groups::NotThere
41             X::WWW::Yahoo::Groups::BadFetch
42             X::WWW::Yahoo::Groups::BadProtected
43              
44             =cut
45              
46             require Exception::Class;
47              
48             Exception::Class->import(
49             'X::WWW::Yahoo::Groups' => {
50             description => 'An error related to WWW::Yahoo::Groups',
51             fields => [qw( fatal )],
52             },
53             'X::WWW::Yahoo::Groups::BadParam' => {
54             isa => 'X::WWW::Yahoo::Groups',
55             description => 'Invalid parameters specified for function',
56             },
57             'X::WWW::Yahoo::Groups::BadLogin' => {
58             isa => 'X::WWW::Yahoo::Groups',
59             description => 'For some reason, your login failed',
60             },
61             'X::WWW::Yahoo::Groups::NoHere' => {
62             isa => 'X::WWW::Yahoo::Groups',
63             description => "The ``here'' link was not found on the login page.",
64             },
65             'X::WWW::Yahoo::Groups::AlreadyLoggedIn' => {
66             isa => 'X::WWW::Yahoo::Groups',
67             description => 'You are already logged in with this object.',
68             },
69             'X::WWW::Yahoo::Groups::NotLoggedIn' => {
70             isa => 'X::WWW::Yahoo::Groups',
71             description => 'You must be logged in to perform that method.',
72             },
73             'X::WWW::Yahoo::Groups::NoListSet' => {
74             isa => 'X::WWW::Yahoo::Groups',
75             description => 'You tried accessing a method that required the list to be set',
76             },
77             'X::WWW::Yahoo::Groups::UnexpectedPage' => {
78             isa => 'X::WWW::Yahoo::Groups',
79             description => 'We received a page that I do not understand',
80             },
81             'X::WWW::Yahoo::Groups::NotThere' => {
82             isa => 'X::WWW::Yahoo::Groups',
83             description => 'The message you wanted is not in the archive',
84             },
85             'X::WWW::Yahoo::Groups::BadFetch' => {
86             isa => 'X::WWW::Yahoo::Groups',
87             description => 'We tried fetching a page, but failed',
88             },
89             'X::WWW::Yahoo::Groups::BadProtected' => {
90             isa => 'X::WWW::Yahoo::Groups',
91             description => 'Protected string contains unknown control sequence. Table needs amending.',
92             },
93             );
94              
95             =head1 USE OF THIS MODULE
96              
97             Due to the nature of how L works, we store
98             common options for it in this class (as they mostly relate to
99             error handling). Thus, you should import this module with the
100             following idiom:
101              
102             require WWW::Yahoo::Groups::Errors;
103             Params::Validate::validation_options(
104             WWW::Yahoo::Groups::Errors->import()
105             );
106              
107              
108             =cut
109              
110             sub import
111             {
112 24     24   68 my ($class) = @_;
113             return (
114             ignore_case => 1,
115             strip_leading => 1,
116             on_fail => sub {
117 30     30   48 chomp($_[0]);
118 30         125 X::WWW::Yahoo::Groups::BadParam->throw(error => $_[0], fatal => 1);
119             }
120 24         286 );
121             }
122              
123             1;
124              
125             __DATA__