Back to index

openldap  2.4.31
Public Member Functions | Private Attributes | Friends
LDAPException Class Reference

This class is only thrown as an Exception and used to signalize error conditions during LDAP-operations. More...

#include <LDAPException.h>

Inheritance diagram for LDAPException:
Inheritance graph
[legend]
Collaboration diagram for LDAPException:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LDAPException (int res_code, const std::string &err_string=std::string()) throw ()
 Constructs a LDAPException-object from the parameters.
 LDAPException (const LDAPAsynConnection *lc) throw ()
 Constructs a LDAPException-object from the error state of a LDAPAsynConnection-object.
virtual ~LDAPException () throw ()
 Destructor.
int getResultCode () const throw ()
const std::string & getResultMsg () const throw ()
const std::string & getServerMsg () const throw ()
virtual const char * what () const throw ()

Private Attributes

int m_res_code
std::string m_res_string
std::string m_err_string

Friends

std::ostream & operator<< (std::ostream &s, LDAPException e) throw ()
 This method can be used to dump the data of a LDAPResult-Object.

Detailed Description

This class is only thrown as an Exception and used to signalize error conditions during LDAP-operations.

Definition at line 23 of file LDAPException.h.


Constructor & Destructor Documentation

LDAPException::LDAPException ( int  res_code,
const std::string &  err_string = std::string() 
) throw ()

Constructs a LDAPException-object from the parameters.

Parameters:
res_codeA valid LDAP result code.
err_stringAn addional error message for the error that happend (optional)

Definition at line 16 of file LDAPException.cpp.

    : std::runtime_error(err_string)
{
       m_res_code=res_code;
       m_res_string=string(ldap_err2string(res_code));
    m_err_string=err_string;
}

Here is the call graph for this function:

Constructs a LDAPException-object from the error state of a LDAPAsynConnection-object.

Parameters:
lcA LDAP-Connection for that an error has happend. The Constructor tries to read its error state.

Definition at line 24 of file LDAPException.cpp.

    : std::runtime_error("")
{
    LDAP *l = lc->getSessionHandle();
    ldap_get_option(l,LDAP_OPT_RESULT_CODE,&m_res_code);
    const char *res_cstring = ldap_err2string(m_res_code);
    if ( res_cstring ) {
        m_res_string = string(res_cstring);
    } else {
        m_res_string = "";
    }
    const char* err_string;

#ifdef LDAP_OPT_DIAGNOSTIC_MESSAGE
    ldap_get_option(l,LDAP_OPT_DIAGNOSTIC_MESSAGE ,&err_string);
#else
    ldap_get_option(l,LDAP_OPT_ERROR_STRING,&err_string);
#endif
    if ( err_string ) {
        m_err_string = string(err_string);
    } else {
        m_err_string = "";
    }
}

Here is the call graph for this function:

LDAPException::~LDAPException ( ) throw () [virtual]

Destructor.

Definition at line 49 of file LDAPException.cpp.

{
}

Member Function Documentation

int LDAPException::getResultCode ( ) const throw ()
Returns:
The Result code of the object

Definition at line 53 of file LDAPException.cpp.

{
       return m_res_code;
}
const string & LDAPException::getResultMsg ( ) const throw ()
Returns:
The error message that is corresponding to the result code .

Definition at line 58 of file LDAPException.cpp.

{
       return m_res_string;
}
const string & LDAPException::getServerMsg ( ) const throw ()
Returns:
The addional error message of the error (if it was set)

Definition at line 63 of file LDAPException.cpp.

{
    return m_err_string;
}
const char * LDAPException::what ( ) const throw () [virtual]

Definition at line 68 of file LDAPException.cpp.

{
    return this->m_res_string.c_str(); 
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
LDAPException  e 
) throw () [friend]

This method can be used to dump the data of a LDAPResult-Object.

It is only useful for debugging purposes at the moment

Definition at line 73 of file LDAPException.cpp.

{
       s << "Error " << e.m_res_code << ": " << e.m_res_string;
       if (!e.m_err_string.empty()) {
              s << endl <<  "additional info: " << e.m_err_string ;
       }
       return s;
}

Member Data Documentation

std::string LDAPException::m_err_string [private]

Definition at line 77 of file LDAPException.h.

Definition at line 75 of file LDAPException.h.

std::string LDAPException::m_res_string [private]

Definition at line 76 of file LDAPException.h.


The documentation for this class was generated from the following files: