-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimaputils.hpp
68 lines (62 loc) · 2.92 KB
/
imaputils.hpp
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
#ifndef IMAPUTILS_H
#define IMAPUTILS_H
#include <libetpan/libetpan.h>
#include <map>
#include <string>
std::map<int, std::string> const errors{
{MAILIMAP_NO_ERROR, "MAILIMAP_NO_ERROR"},
{MAILIMAP_NO_ERROR_AUTHENTICATED, "MAILIMAP_NO_ERROR_AUTHENTICATED"},
{MAILIMAP_NO_ERROR_NON_AUTHENTICATED, "MAILIMAP_NO_ERROR_NON_AUTHENTICATED"},
{MAILIMAP_ERROR_BAD_STATE, "MAILIMAP_ERROR_BAD_STATE"},
{MAILIMAP_ERROR_STREAM, "MAILIMAP_ERROR_STREAM"},
{MAILIMAP_ERROR_PARSE, "MAILIMAP_ERROR_PARSE"},
{MAILIMAP_ERROR_CONNECTION_REFUSED, "MAILIMAP_ERROR_CONNECTION_REFUSED"},
{MAILIMAP_ERROR_MEMORY, "MAILIMAP_ERROR_MEMORY"},
{MAILIMAP_ERROR_FATAL, "MAILIMAP_ERROR_FATAL"},
{MAILIMAP_ERROR_PROTOCOL, "MAILIMAP_ERROR_PROTOCOL"},
{MAILIMAP_ERROR_DONT_ACCEPT_CONNECTION, "MAILIMAP_ERROR_DONT_ACCEPT_CONNECTION"},
{MAILIMAP_ERROR_APPEND, "MAILIMAP_ERROR_APPEND"},
{MAILIMAP_ERROR_NOOP, "MAILIMAP_ERROR_NOOP"},
{MAILIMAP_ERROR_LOGOUT, "MAILIMAP_ERROR_LOGOUT"},
{MAILIMAP_ERROR_CAPABILITY, "MAILIMAP_ERROR_CAPABILITY"},
{MAILIMAP_ERROR_CHECK, "MAILIMAP_ERROR_CHECK"},
{MAILIMAP_ERROR_CLOSE, "MAILIMAP_ERROR_CLOSE"},
{MAILIMAP_ERROR_EXPUNGE, "MAILIMAP_ERROR_EXPUNGE"},
{MAILIMAP_ERROR_COPY, "MAILIMAP_ERROR_COPY"},
{MAILIMAP_ERROR_UID_COPY, "MAILIMAP_ERROR_UID_COPY"},
{MAILIMAP_ERROR_MOVE, "MAILIMAP_ERROR_MOVE"},
{MAILIMAP_ERROR_UID_MOVE, "MAILIMAP_ERROR_UID_MOVE"},
{MAILIMAP_ERROR_CREATE, "MAILIMAP_ERROR_CREATE"},
{MAILIMAP_ERROR_DELETE, "MAILIMAP_ERROR_DELETE"},
{MAILIMAP_ERROR_EXAMINE, "MAILIMAP_ERROR_EXAMINE"},
{MAILIMAP_ERROR_FETCH, "MAILIMAP_ERROR_FETCH"},
{MAILIMAP_ERROR_UID_FETCH, "MAILIMAP_ERROR_UID_FETCH"},
{MAILIMAP_ERROR_LIST, "MAILIMAP_ERROR_LIST"},
{MAILIMAP_ERROR_LOGIN, "MAILIMAP_ERROR_LOGIN"},
{MAILIMAP_ERROR_LSUB, "MAILIMAP_ERROR_LSUB"},
{MAILIMAP_ERROR_RENAME, "MAILIMAP_ERROR_RENAME"},
{MAILIMAP_ERROR_SEARCH, "MAILIMAP_ERROR_SEARCH"},
{MAILIMAP_ERROR_UID_SEARCH, "MAILIMAP_ERROR_UID_SEARCH"},
{MAILIMAP_ERROR_SELECT, "MAILIMAP_ERROR_SELECT"},
{MAILIMAP_ERROR_STATUS, "MAILIMAP_ERROR_STATUS"},
{MAILIMAP_ERROR_STORE, "MAILIMAP_ERROR_STORE"},
{MAILIMAP_ERROR_UID_STORE, "MAILIMAP_ERROR_UID_STORE"},
{MAILIMAP_ERROR_SUBSCRIBE, "MAILIMAP_ERROR_SUBSCRIBE"},
{MAILIMAP_ERROR_UNSUBSCRIBE, "MAILIMAP_ERROR_UNSUBSCRIBE"},
{MAILIMAP_ERROR_STARTTLS, "MAILIMAP_ERROR_STARTTLS"},
{MAILIMAP_ERROR_INVAL, "MAILIMAP_ERROR_INVAL"},
{MAILIMAP_ERROR_EXTENSION, "MAILIMAP_ERROR_EXTENSION"},
{MAILIMAP_ERROR_SASL, "MAILIMAP_ERROR_SASL"},
{MAILIMAP_ERROR_SSL, "MAILIMAP_ERROR_SSL"},
{MAILIMAP_ERROR_NEEDS_MORE_DATA, "MAILIMAP_ERROR_NEEDS_MORE_DATA"},
{MAILIMAP_ERROR_CUSTOM_COMMAND, "MAILIMAP_ERROR_CUSTOM_COMMAND"}};
static void check_error(int r, std::string const& msg) {
if(r == MAILIMAP_NO_ERROR)
return;
if(r == MAILIMAP_NO_ERROR_AUTHENTICATED)
return;
if(r == MAILIMAP_NO_ERROR_NON_AUTHENTICATED)
return;
throw std::runtime_error(msg + " " + errors.at(r));
}
#endif /* IMAPUTILS_H */