2 * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 // $Id: LDAPException.cpp,v 1.7 2000/08/31 17:43:48 rhafer Exp $
11 #include "ac/string.h"
12 #include "LDAPException.h"
14 LDAPException::LDAPException(int res_code, char *err_string=0){
16 m_res_string=ldap_err2string(res_code);
18 m_err_string=strdup(err_string);
24 LDAPException::LDAPException(const LDAPAsynConnection *lc){
27 LDAP *l = lc->getSessionHandle();
28 ldap_get_option(l,LDAP_OPT_ERROR_NUMBER,&m_res_code);
29 m_res_string=ldap_err2string(m_res_code);
30 ldap_get_option(l,LDAP_OPT_ERROR_STRING,&m_err_string);
33 int LDAPException::getResultCode(){
37 char* LDAPException::getResultMsg(){
38 return strdup(m_res_string);
41 ostream& operator << (ostream& s, LDAPException e){
42 s << "Error " << e.m_res_code << ": " << e.m_res_string;
43 if (e.m_err_string != 0) {
44 s << endl << "additional info: " << e.m_err_string ;