1
// $OpenLDAP: pkg/ldap/contrib/ldapc++/src/LDAPException.cpp,v 1.8.2.5 2008/04/14 23:09:26 quanah Exp $
3
* Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
4
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
9
#include "LDAPException.h"
11
#include "LDAPAsynConnection.h"
12
#include "LDAPResult.h"
16
LDAPException::LDAPException(int res_code, const string& err_string) throw()
17
: std::runtime_error(err_string)
20
m_res_string=string(ldap_err2string(res_code));
21
m_err_string=err_string;
24
LDAPException::LDAPException(const LDAPAsynConnection *lc) throw()
25
: std::runtime_error("")
27
LDAP *l = lc->getSessionHandle();
28
ldap_get_option(l,LDAP_OPT_RESULT_CODE,&m_res_code);
29
const char *res_cstring = ldap_err2string(m_res_code);
31
m_res_string = string(res_cstring);
35
const char* err_string;
37
#ifdef LDAP_OPT_DIAGNOSTIC_MESSAGE
38
ldap_get_option(l,LDAP_OPT_DIAGNOSTIC_MESSAGE ,&err_string);
40
ldap_get_option(l,LDAP_OPT_ERROR_STRING,&err_string);
43
m_err_string = string(err_string);
49
LDAPException::~LDAPException() throw()
53
int LDAPException::getResultCode() const throw()
58
const string& LDAPException::getResultMsg() const throw()
63
const string& LDAPException::getServerMsg() const throw()
68
const char* LDAPException::what() const throw()
70
return this->m_res_string.c_str();
73
ostream& operator << (ostream& s, LDAPException e) throw()
75
s << "Error " << e.m_res_code << ": " << e.m_res_string;
76
if (!e.m_err_string.empty()) {
77
s << endl << "additional info: " << e.m_err_string ;
83
LDAPReferralException::LDAPReferralException(const LDAPUrlList& urls) throw()
84
: LDAPException(LDAPResult::REFERRAL) , m_urlList(urls)
88
LDAPReferralException::~LDAPReferralException() throw()
92
const LDAPUrlList& LDAPReferralException::getUrls() throw()