]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPException.h
some changes to make the library working with gcc 3.0 (mostly namespace
[openldap] / contrib / ldapc++ / src / LDAPException.h
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6
7 #ifndef LDAP_EXCEPTION_H
8 #define LDAP_EXCEPTION_H
9
10 #include <iostream>
11 #include <string>
12
13 class LDAPAsynConnection;
14
15 /**
16  * This class is only thrown as an Exception and used to signalize error
17  * conditions during LDAP-operations
18  */
19 class LDAPException{
20                 
21         public :
22         /**
23          * Constructs a LDAPException-object from the parameters
24          * @param res_code A valid LDAP result code.
25          * @param err_std::string    An addional error message for the error
26          *                      that happend (optional)
27          */
28                 LDAPException(int res_code, const std::string& err_string=std::string());
29                 
30         /**
31          * Constructs a LDAPException-object from the error state of a
32          * LDAPAsynConnection-object
33          * @param lc A LDAP-Connection for that an error has happend. The
34          *          Constructor tries to read its error state.
35          */
36         LDAPException(const LDAPAsynConnection *lc);
37
38         /**
39          * Destructor
40          */
41         virtual ~LDAPException();
42
43         /**
44          * @return The Result code of the object
45          */
46         
47                 int getResultCode() const;
48
49         /**
50          * @return The error message that is corresponding to the result
51          *          code .
52          */
53                 const std::string& getResultMsg() const;
54         
55         /**
56          * @return The addional error message of the error (if it was set)
57          */
58         const std::string& getServerMsg() const;
59
60         /**
61          * This method can be used to dump the data of a LDAPResult-Object.
62          * It is only useful for debugging purposes at the moment
63          */
64                 friend std::ostream& operator << (std::ostream &s, LDAPException e);
65
66         private :
67                 int m_res_code;
68                 std::string m_res_string;
69                 std::string m_err_string;
70 };
71 #endif //LDAP_EXCEPTION_H