1package WWW::Mediawiki::Client::Exceptions;
2
3use strict;
4use warnings;
5use Exception::Class (
6
7    'WWW::Mediawiki::Client::Exception' =>
8        { description => 'A base clase for WWW::Mediawiki::Client exceptions.'},
9
10    'WWW::Mediawiki::Client::URLConstructionException' =>
11        {
12            isa => 'WWW::Mediawiki::Client::Exception',
13            description => 'Indicates a problem with the URL with which we to call the Mediawiki server.',
14        },
15
16    'WWW::Mediawiki::Client::AuthException' =>
17        {
18            isa => 'WWW::Mediawiki::Client::Exception',
19            description => 'Indicates a problem with the provided authentication information',
20        },
21
22    'WWW::Mediawiki::Client::LoginException' =>
23        {
24            isa => 'WWW::Mediawiki::Client::Exception',
25            description => 'Indicates that login failed for an unknown reason',
26            fields => ['res', 'cookie_jar'],
27        },
28
29    'WWW::Mediawiki::Client::CookieJarException' =>
30        {
31            isa => 'WWW::Mediawiki::Client::Exception',
32            description => 'Something went wrong saving or loading the cookie jar',
33        },
34
35    'WWW::Mediawiki::Client::FileAccessException' =>
36        {
37            isa => 'WWW::Mediawiki::Client::Exception',
38            description => 'Something went wrong saving or loading a file',
39        },
40
41    'WWW::Mediawiki::Client::FileTypeException' =>
42        {
43            isa => 'WWW::Mediawiki::Client::Exception',
44            description => 'The file which we attempted to operate on is not a .wiki file',
45        },
46
47    'WWW::Mediawiki::Client::AbsoluteFileNameException' =>
48        {
49            isa => 'WWW::Mediawiki::Client::Exception',
50            description => 'The file which we attempted to operate on is not a .wiki file',
51        },
52
53    'WWW::Mediawiki::Client::CommitException' =>
54        {
55            isa => 'WWW::Mediawiki::Client::Exception',
56            description => 'Something went wrong while committing a change.',
57            fields => ['res'],
58        },
59
60    'WWW::Mediawiki::Client::CommitMessageException' =>
61        {
62            isa => 'WWW::Mediawiki::Client::Exception',
63            description => 'There is a problem with the commit message',
64        },
65
66    'WWW::Mediawiki::Client::PageDoesNotExistException' =>
67        {
68            isa => 'WWW::Mediawiki::Client::Exception',
69            description => 'There is no such page, either here or on the server',
70        },
71
72    'WWW::Mediawiki::Client::UpdateNeededException' =>
73        {
74            isa => 'WWW::Mediawiki::Client::Exception',
75            description => 'The page on the server has changed since the local file was last updated',
76        },
77
78    'WWW::Mediawiki::Client::ConflictsPresentException' =>
79        {
80            isa => 'WWW::Mediawiki::Client::Exception',
81            description => 'An attempt was made to commit a file containing conflicts',
82        },
83
84    'WWW::Mediawiki::Client::CorruptedConfigFileException'  =>
85        {
86            isa => 'WWW::Mediawiki::Client::Exception',
87            description => 'The configuration file cannot be parsed.',
88        },
89
90    'WWW::Mediawiki::Client::ServerPageException' =>
91        {
92            isa => 'WWW::Mediawiki::Client::Exception',
93            description => 'Something went wrong fetching the server page.',
94            fields => ['res'],
95        },
96
97    'WWW::Mediawiki::Client::ReadOnlyFieldException' =>
98        {
99            isa => 'WWW::Mediawiki::Client::Exception',
100            description => 'Client code tried to set a read-only field.',
101        },
102
103    'WWW::Mediawiki::Client::InvalidOptionException' =>
104        {
105            isa => 'WWW::Mediawiki::Client::Exception',
106            description => 'Client code tried to set an option to a value'
107	    	. ' that cannot be used under the circumstances.',
108	    fields => ['field', 'option', 'value'],
109        },
110);
111
112WWW::Mediawiki::Client::Exception->Trace(1);
113
1141;
115
116__END__
117
118=head1 NAME
119
120WWW::Mediawiki::Client::Exception
121
122=head1 SYNOPSIS
123
124  use WWW::Mediawiki::Client::Exception;
125  use Data::Dumper;
126
127  # throw
128  eval {
129      WWW::Mediawiki::Client::LoginException->throw(
130              error      => 'Something bad happened',
131              res        => $res,
132              cookie_jar => $cookie_jar,
133          );
134  };
135
136  # catch
137  if (UNIVERSAL::isa($@, 'WWW::Mediawiki::Client::LoginException') {
138      print STDERR $@->error;
139      print Dumper($@->res);
140  }
141
142=head1 DESCRIPTION
143
144A base class for WWW::Mediawiki::Client exceptions.
145
146=head1 SUBCLASSES
147
148=head2 WWW::Mediawiki::Client::URLConstructionException
149
150Indicates a problem with the URL with which we to the Mediawiki server.
151
152=head2 WWW::Mediawiki::Client::AuthException
153
154Indicates a problem with the provided authentication information
155
156=head2 WWW::Mediawiki::Client::LoginException
157
158Indicates that login failed for an unknown reason
159
160B<Fields:>
161
162=over
163
164=item res
165
166For the apache response object returned by the attempt to log in.
167
168=item cookie_jar
169
170For the cookie jar which was returned by the attempt to log in.
171
172=back
173
174=head2 WWW::Mediawiki::Client::CookieJarException
175
176Something went wrong saving or loading the cookie jar
177
178=head2 WWW::Mediawiki::Client::FileAccessException
179
180Something went wrong saving or loading a file
181
182=head2 WWW::Mediawiki::Client::FileTypeException
183
184The file which we attempted to operate on is not a .wiki file
185
186=head2 WWW::Mediawiki::Client::AbsoluteFileNameException
187
188The file which we attempted to operate on is not a .wiki file
189
190=head2 WWW::Mediawiki::Client::CommitMessageException
191
192There is a problem with the commit message
193
194=head2 WWW::Mediawiki::Client::CommitException
195
196Something went wrong while committing a change
197
198=head2 WWW::Mediawiki::Client::PageDoesNotExistException
199
200There is no such page, either here or on the server
201
202=head2 WWW::Mediawiki::Client::UpdateNeededException
203
204The page on the server has changed since the local file was last updated
205
206=head2 WWW::Mediawiki::Client::ConflictsPresentException
207
208An attempt was made to commit a file containing conflicts
209
210=head2 WWW::Mediawiki::Client::CorruptedConfigFileException
211
212The configuration file cannot be parsed.
213
214=head2 WWW::Mediawiki::Client::ServerPageException
215
216Something went wrong fetching the server page.
217
218B<Throws:>
219
220=over
221
222=item res
223
224The apache response object which was returned in the attempt to fetch the page.
225
226=back
227
228=head2 WWW::Mediawiki::Client::ReadOnlyFieldException
229
230Client code tried to set a read-only field.
231
232=head1 SEE ALSO
233
234Exception::Class
235
236=head1 AUTHORS
237
238=item Mark Jaroski <mark@geekhive.net>
239
240Author
241
242=item Bernhard Kaindl <bkaindl@ffii.org>
243
244Inspired the improvement in error handling and reporting.
245
246=head1 LICENSE
247
248Copyright (c) 2004 Mark Jaroski.
249
250This program is free software; you can redistribute it and/or modify it under
251the same terms as Perl itself.
252
253