1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
|
//
// VMime library (http://vmime.sourceforge.net)
// Copyright (C) 2002-2005 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include "vmime/exception.hpp"
namespace vmime {
//
// exception
//
const exception exception::NO_EXCEPTION;
exception::exception()
: m_what(""), m_other(NULL)
{
}
exception::exception(const string& what, const exception& other)
: m_what(what), m_other(&other != &NO_EXCEPTION ? other.clone() : NULL)
{
}
exception::~exception()
{
delete (m_other);
}
const string exception::what() const throw()
{
return (m_what);
}
const exception* exception::other() const
{
return (m_other);
}
const string exception::name() const
{
return "exception";
}
exception* exception::clone() const
{
return new exception(*this);
}
namespace exceptions
{
//
// bad_field_type
//
bad_field_type::~bad_field_type() throw() {}
bad_field_type::bad_field_type(const exception& other)
: exception("Bad field type.", other) {}
exception* bad_field_type::clone() const { return new bad_field_type(*this); }
const string bad_field_type::name() const { return "bad_field_type"; }
//
// charset_conv_error
//
charset_conv_error::~charset_conv_error() throw() {}
charset_conv_error::charset_conv_error(const exception& other)
: exception("Charset conversion error.", other) {}
exception* charset_conv_error::clone() const { return new charset_conv_error(*this); }
const string charset_conv_error::name() const { return "charset_conv_error"; }
//
// no_encoder_available
//
no_encoder_available::~no_encoder_available() throw() {}
no_encoder_available::no_encoder_available(const exception& other)
: exception("No encoder available.", other) {}
exception* no_encoder_available::clone() const { return new no_encoder_available(*this); }
const string no_encoder_available::name() const { return "no_encoder_available"; }
//
// no_such_parameter
//
no_such_parameter::~no_such_parameter() throw() {}
no_such_parameter::no_such_parameter(const string& name, const exception& other)
: exception(string("Parameter not found: '") + name + string("'."), other) {}
exception* no_such_parameter::clone() const { return new no_such_parameter(*this); }
const string no_such_parameter::name() const { return "no_such_parameter"; }
//
// no_such_field
//
no_such_field::~no_such_field() throw() {}
no_such_field::no_such_field(const exception& other)
: exception("Field not found.", other) {}
exception* no_such_field::clone() const { return new no_such_field(*this); }
const string no_such_field::name() const { return "no_such_field"; }
//
// no_such_part
//
no_such_part::~no_such_part() throw() {}
no_such_part::no_such_part(const exception& other)
: exception("Part not found.", other) {}
exception* no_such_part::clone() const { return new no_such_part(*this); }
const string no_such_part::name() const { return "no_such_part"; }
//
// no_such_mailbox
//
no_such_mailbox::~no_such_mailbox() throw() {}
no_such_mailbox::no_such_mailbox(const exception& other)
: exception("Mailbox not found.", other) {}
exception* no_such_mailbox::clone() const { return new no_such_mailbox(*this); }
const string no_such_mailbox::name() const { return "no_such_mailbox"; }
//
// no_such_address
//
no_such_address::~no_such_address() throw() {}
no_such_address::no_such_address(const exception& other)
: exception("Address not found.", other) {}
exception* no_such_address::clone() const { return new no_such_address(*this); }
const string no_such_address::name() const { return "no_such_address"; }
//
// open_file_error
//
open_file_error::~open_file_error() throw() {}
open_file_error::open_file_error(const exception& other)
: exception("Error opening file.", other) {}
exception* open_file_error::clone() const { return new open_file_error(*this); }
const string open_file_error::name() const { return "open_file_error"; }
//
// no_factory_available
//
no_factory_available::~no_factory_available() throw() {}
no_factory_available::no_factory_available(const exception& other)
: exception("No factory available.", other) {}
exception* no_factory_available::clone() const { return new no_factory_available(*this); }
const string no_factory_available::name() const { return "no_factory_available"; }
//
// no_platform_dependant_handler
//
no_platform_dependant_handler::~no_platform_dependant_handler() throw() {}
no_platform_dependant_handler::no_platform_dependant_handler(const exception& other)
: exception("No platform-dependant handler installed.", other) {}
exception* no_platform_dependant_handler::clone() const { return new no_platform_dependant_handler(*this); }
const string no_platform_dependant_handler::name() const { return "no_platform_dependant_handler"; }
//
// no_expeditor
//
no_expeditor::~no_expeditor() throw() {}
no_expeditor::no_expeditor(const exception& other)
: exception("No expeditor specified.", other) {}
exception* no_expeditor::clone() const { return new no_expeditor(*this); }
const string no_expeditor::name() const { return "no_expeditor"; }
//
// no_recipient
//
no_recipient::~no_recipient() throw() {}
no_recipient::no_recipient(const exception& other)
: exception("No recipient specified.", other) {}
exception* no_recipient::clone() const { return new no_recipient(*this); }
const string no_recipient::name() const { return "no_recipient"; }
//
// no_object_found
//
no_object_found::~no_object_found() throw() {}
no_object_found::no_object_found(const exception& other)
: exception("No object found.", other) {}
exception* no_object_found::clone() const { return new no_object_found(*this); }
const string no_object_found::name() const { return "no_object_found"; }
//
// no_such_property
//
no_such_property::~no_such_property() throw() {}
no_such_property::no_such_property(const string& name, const exception& other)
: exception(std::string("No such property: '") + name + string("'."), other) { }
exception* no_such_property::clone() const { return new no_such_property(*this); }
const string no_such_property::name() const { return "no_such_property"; }
//
// invalid_property_type
//
invalid_property_type::~invalid_property_type() throw() {}
invalid_property_type::invalid_property_type(const exception& other)
: exception("Invalid property type.", other) {}
exception* invalid_property_type::clone() const { return new invalid_property_type(*this); }
const string invalid_property_type::name() const { return "invalid_property_type"; }
//
// invalid_argument
//
invalid_argument::~invalid_argument() throw() {}
invalid_argument::invalid_argument(const exception& other)
: exception("Invalid argument.", other) {}
exception* invalid_argument::clone() const { return new invalid_argument(*this); }
const string invalid_argument::name() const { return "invalid_argument"; }
#if VMIME_HAVE_MESSAGING_FEATURES
//
// messaging_exception
//
messaging_exception::~messaging_exception() throw() {}
messaging_exception::messaging_exception(const string& what, const exception& other)
: exception(what, other) {}
exception* messaging_exception::clone() const { return new messaging_exception(*this); }
const string messaging_exception::name() const { return "messaging_exception"; }
//
// connection_error
//
connection_error::~connection_error() throw() {}
connection_error::connection_error(const string& what, const exception& other)
: messaging_exception(what.empty()
? "Connection error."
: "Connection error: '" + what + "'.", other) {}
exception* connection_error::clone() const { return new connection_error(*this); }
const string connection_error::name() const { return "connection_error"; }
//
// connection_greeting_error
//
connection_greeting_error::~connection_greeting_error() throw() {}
connection_greeting_error::connection_greeting_error(const string& response, const exception& other)
: messaging_exception("Greeting error.", other), m_response(response) {}
const string& connection_greeting_error::response() const { return (m_response); }
exception* connection_greeting_error::clone() const { return new connection_greeting_error(*this); }
const string connection_greeting_error::name() const { return "connection_greeting_error"; }
//
// authentication_error
//
authentication_error::~authentication_error() throw() {}
authentication_error::authentication_error(const string& response, const exception& other)
: messaging_exception("Authentication error.", other), m_response(response) {}
const string& authentication_error::response() const { return (m_response); }
exception* authentication_error::clone() const { return new authentication_error(*this); }
const string authentication_error::name() const { return "authentication_error"; }
//
// unsupported_option
//
unsupported_option::~unsupported_option() throw() {}
unsupported_option::unsupported_option(const exception& other)
: messaging_exception("Unsupported option.", other) {}
exception* unsupported_option::clone() const { return new unsupported_option(*this); }
const string unsupported_option::name() const { return "unsupported_option"; }
//
// no_service_available
//
no_service_available::~no_service_available() throw() {}
no_service_available::no_service_available(const string& proto, const exception& other)
: messaging_exception(proto.empty()
? "No service available for this protocol."
: "No service available for this protocol: '" + proto + "'.", other) {}
exception* no_service_available::clone() const { return new no_service_available(*this); }
const string no_service_available::name() const { return "no_service_available"; }
//
// illegal_state
//
illegal_state::~illegal_state() throw() {}
illegal_state::illegal_state(const string& state, const exception& other)
: messaging_exception("Illegal state to accomplish the operation: '" + state + "'.", other) {}
exception* illegal_state::clone() const { return new illegal_state(*this); }
const string illegal_state::name() const { return "illegal_state"; }
//
// folder_not_found
//
folder_not_found::~folder_not_found() throw() {}
folder_not_found::folder_not_found(const exception& other)
: messaging_exception("Folder not found.", other) {}
exception* folder_not_found::clone() const { return new folder_not_found(*this); }
const string folder_not_found::name() const { return "folder_not_found"; }
//
// message_not_found
//
message_not_found::~message_not_found() throw() {}
message_not_found::message_not_found(const exception& other)
: messaging_exception("Message not found.", other) {}
exception* message_not_found::clone() const { return new message_not_found(*this); }
const string message_not_found::name() const { return "message_not_found"; }
//
// operation_not_supported
//
operation_not_supported::~operation_not_supported() throw() {}
operation_not_supported::operation_not_supported(const exception& other)
: messaging_exception("Operation not supported.", other) {}
exception* operation_not_supported::clone() const { return new operation_not_supported(*this); }
const string operation_not_supported::name() const { return "operation_not_supported"; }
//
// operation_timed_out
//
operation_timed_out::~operation_timed_out() throw() {}
operation_timed_out::operation_timed_out(const exception& other)
: messaging_exception("Operation timed out.", other) {}
exception* operation_timed_out::clone() const { return new operation_timed_out(*this); }
const string operation_timed_out::name() const { return "operation_timed_out"; }
//
// operation_cancelled
//
operation_cancelled::~operation_cancelled() throw() {}
operation_cancelled::operation_cancelled(const exception& other)
: messaging_exception("Operation cancelled by the user.", other) {}
exception* operation_cancelled::clone() const { return new operation_cancelled(*this); }
const string operation_cancelled::name() const { return "operation_cancelled"; }
//
// unfetched_object
//
unfetched_object::~unfetched_object() throw() {}
unfetched_object::unfetched_object(const exception& other)
: messaging_exception("Object not fetched.", other) {}
exception* unfetched_object::clone() const { return new unfetched_object(*this); }
const string unfetched_object::name() const { return "unfetched_object"; }
//
// not_connected
//
not_connected::~not_connected() throw() {}
not_connected::not_connected(const exception& other)
: messaging_exception("Not connected to a service.", other) {}
exception* not_connected::clone() const { return new not_connected(*this); }
const string not_connected::name() const { return "not_connected"; }
//
// already_connected
//
already_connected::~already_connected() throw() {}
already_connected::already_connected(const exception& other)
: messaging_exception("Already connected to a service. Disconnect and retry.", other) {}
exception* already_connected::clone() const { return new already_connected(*this); }
const string already_connected::name() const { return "already_connected"; }
//
// illegal_operation
//
illegal_operation::~illegal_operation() throw() {}
illegal_operation::illegal_operation(const string& msg, const exception& other)
: messaging_exception(msg.empty()
? "Illegal operation."
: "Illegal operation: " + msg + ".",
other
) {}
exception* illegal_operation::clone() const { return new illegal_operation(*this); }
const string illegal_operation::name() const { return "illegal_operation"; }
//
// command_error
//
command_error::~command_error() throw() {}
command_error::command_error(const string& command, const string& response,
const string& desc, const exception& other)
: messaging_exception(desc.empty()
? "Error while executing command '" + command + "'."
: "Error while executing command '" + command + "': " + desc + ".",
other
),
m_command(command), m_response(response) {}
const string& command_error::command() const { return (m_command); }
const string& command_error::response() const { return (m_response); }
exception* command_error::clone() const { return new command_error(*this); }
const string command_error::name() const { return "command_error"; }
//
// invalid_response
//
invalid_response::~invalid_response() throw() {}
invalid_response::invalid_response(const string& command, const string& response, const exception& other)
: messaging_exception(command.empty()
? "Received invalid response."
: "Received invalid response for command '" + command + "'.",
other
),
m_command(command), m_response(response) {}
const string& invalid_response::command() const { return (m_command); }
const string& invalid_response::response() const { return (m_response); }
exception* invalid_response::clone() const { return new invalid_response(*this); }
const string invalid_response::name() const { return "invalid_response"; }
//
// partial_fetch_not_supported
//
partial_fetch_not_supported::~partial_fetch_not_supported() throw() {}
partial_fetch_not_supported::partial_fetch_not_supported(const exception& other)
: messaging_exception("Partial fetch not supported.", other) {}
exception* partial_fetch_not_supported::clone() const { return new partial_fetch_not_supported(*this); }
const string partial_fetch_not_supported::name() const { return "partial_fetch_not_supported"; }
//
// malformed_url
//
malformed_url::~malformed_url() throw() {}
malformed_url::malformed_url(const string& error, const exception& other)
: messaging_exception("Malformed URL: " + error + ".", other) {}
exception* malformed_url::clone() const { return new malformed_url(*this); }
const string malformed_url::name() const { return "malformed_url"; }
//
// invalid_folder_name
//
invalid_folder_name::~invalid_folder_name() throw() {}
invalid_folder_name::invalid_folder_name(const string& error, const exception& other)
: messaging_exception(error.empty()
? "Invalid folder name: " + error + "."
: "Invalid folder name.",
other) {}
exception* invalid_folder_name::clone() const { return new invalid_folder_name(*this); }
const string invalid_folder_name::name() const { return "invalid_folder_name"; }
#endif // VMIME_HAVE_MESSAGING_FEATURES
#if VMIME_HAVE_FILESYSTEM_FEATURES
//
// filesystem_exception
//
filesystem_exception::~filesystem_exception() throw() {}
filesystem_exception::filesystem_exception(const string& what, const utility::path& path, const exception& other)
: exception(what, other), m_path(path) {}
const utility::path& filesystem_exception::path() const { return (m_path); }
exception* filesystem_exception::clone() const { return new filesystem_exception(*this); }
const string filesystem_exception::name() const { return "filesystem_exception"; }
//
// not_a_directory
//
not_a_directory::~not_a_directory() throw() {}
not_a_directory::not_a_directory(const utility::path& path, const exception& other)
: filesystem_exception("Operation failed: this is not a directory.", path, other) {}
exception* not_a_directory::clone() const { return new not_a_directory(*this); }
const string not_a_directory::name() const { return "not_a_directory"; }
//
// file_not_found
//
file_not_found::~file_not_found() throw() {}
file_not_found::file_not_found(const utility::path& path, const exception& other)
: filesystem_exception("File not found.", path, other) {}
exception* file_not_found::clone() const { return new file_not_found(*this); }
const string file_not_found::name() const { return "file_not_found"; }
#endif // VMIME_HAVE_FILESYSTEM_FEATURES
} // exceptions
} // vmime
|