-
Notifications
You must be signed in to change notification settings - Fork 0
/
exceptions.cpp
64 lines (60 loc) · 2.72 KB
/
exceptions.cpp
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
#include "exceptions.h"
#include <map>
namespace Ldap {
namespace {
const std::map<ErrorCode, std::string> errorStrings{
{ ErrorCode::success, "success" },
{ ErrorCode::operationsError, "operationsError" },
{ ErrorCode::protocolError, "protocolError" },
{ ErrorCode::timeLimitExceeded, "timeLimitExceeded" },
{ ErrorCode::sizeLimitExceeded, "sizeLimitExceeded" },
{ ErrorCode::compareFalse, "compareFalse" },
{ ErrorCode::compareTrue, "compareTrue" },
{ ErrorCode::authMethodNotSupported, "authMethodNotSupported" },
{ ErrorCode::strongerAuthRequired, "strongerAuthRequired" },
{ ErrorCode::referral, "referral" },
{ ErrorCode::adminLimitExceeded, "adminLimitExceeded" },
{ ErrorCode::unavailableCriticalExtension, "unavailableCriticalExtension" },
{ ErrorCode::confidentialityRequired, "confidentialityRequired" },
{ ErrorCode::saslBindInProgress, "saslBindInProgress" },
{ ErrorCode::noSuchAttribute, "noSuchAttribute" },
{ ErrorCode::undefinedAttributeType, "undefinedAttributeType" },
{ ErrorCode::inappropriateMatching, "inappropriateMatching" },
{ ErrorCode::constraintViolation, "constraintViolation" },
{ ErrorCode::attributeOrValueExists, "attributeOrValueExists" },
{ ErrorCode::invalidAttributeSyntax, "invalidAttributeSyntax" },
{ ErrorCode::noSuchObject, "noSuchObject" },
{ ErrorCode::aliasProblem, "aliasProblem" },
{ ErrorCode::invalidDNSyntax, "invalidDNSyntax" },
{ ErrorCode::aliasDereferencingProblem, "aliasDereferencingProblem" },
{ ErrorCode::inappropriateAuthentication, "inappropriateAuthentication" },
{ ErrorCode::invalidCredentials, "invalidCredentials" },
{ ErrorCode::insufficientAccessRights, "insufficientAccessRights" },
{ ErrorCode::busy, "busy" },
{ ErrorCode::unavailable, "unavailable" },
{ ErrorCode::unwillingToPerform, "unwillingToPerform" },
{ ErrorCode::loopDetect, "loopDetect" },
{ ErrorCode::namingViolation, "namingViolation" },
{ ErrorCode::objectClassViolation, "objectClassViolation" },
{ ErrorCode::notAllowedOnNonLeaf, "notAllowedOnNonLeaf" },
{ ErrorCode::notAllowedOnRDN, "notAllowedOnRDN" },
{ ErrorCode::entryAlreadyExists, "entryAlreadyExists" },
{ ErrorCode::objectClassModsProhibited, "objectClassModsProhibited" },
{ ErrorCode::affectsMultipleDSAs, "affectsMultipleDSAs" },
{ ErrorCode::other, "other" },
};
} // namespace
Exception::Exception(ErrorCode code) :
_code { code },
_what { errorStrings.at(code) }
{}
Exception::Exception(ErrorCode code, const char* what) :
_code { code },
_what { what }
{}
void checkProtocolError(bool exprResult) {
if (!exprResult) {
throw Exception(ErrorCode::protocolError);
}
}
} // namespace Ldap