3 * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
8 #ifndef LDAP_EXCEPTION_H
9 #define LDAP_EXCEPTION_H
15 #include <LDAPUrlList.h>
17 class LDAPAsynConnection;
20 * This class is only thrown as an Exception and used to signalize error
21 * conditions during LDAP-operations
23 class LDAPException : public std::runtime_error
28 * Constructs a LDAPException-object from the parameters
29 * @param res_code A valid LDAP result code.
30 * @param err_string An addional error message for the error
31 * that happend (optional)
33 LDAPException(int res_code,
34 const std::string& err_string=std::string()) throw();
37 * Constructs a LDAPException-object from the error state of a
38 * LDAPAsynConnection-object
39 * @param lc A LDAP-Connection for that an error has happend. The
40 * Constructor tries to read its error state.
42 LDAPException(const LDAPAsynConnection *lc) throw();
47 virtual ~LDAPException() throw();
50 * @return The Result code of the object
52 int getResultCode() const throw();
55 * @return The error message that is corresponding to the result
58 const std::string& getResultMsg() const throw();
61 * @return The addional error message of the error (if it was set)
63 const std::string& getServerMsg() const throw();
66 virtual const char* what() const throw();
69 * This method can be used to dump the data of a LDAPResult-Object.
70 * It is only useful for debugging purposes at the moment
72 friend std::ostream& operator << (std::ostream &s, LDAPException e) throw();
76 std::string m_res_string;
77 std::string m_err_string;
81 * This class extends LDAPException and is used to signalize Referrals
82 * there were received during synchronous LDAP-operations
84 class LDAPReferralException : public LDAPException
89 * Creates an object that is initialized with a list of URLs
91 LDAPReferralException(const LDAPUrlList& urls) throw();
96 ~LDAPReferralException() throw();
99 * @return The List of URLs of the Referral/Search Reference
101 const LDAPUrlList& getUrls() throw();
104 LDAPUrlList m_urlList;
107 #endif //LDAP_EXCEPTION_H