]> git.sur5r.net Git - openldap/commitdiff
derive LDAPException from std::exception, merged ReferralException into the
authorRalf Haferkamp <ralf@openldap.org>
Thu, 20 Mar 2008 15:08:29 +0000 (15:08 +0000)
committerRalf Haferkamp <ralf@openldap.org>
Thu, 20 Mar 2008 15:08:29 +0000 (15:08 +0000)
LDAPException files

contrib/ldapc++/src/LDAPConnection.cpp
contrib/ldapc++/src/LDAPException.cpp
contrib/ldapc++/src/LDAPException.h
contrib/ldapc++/src/LDAPReferralException.cpp [deleted file]
contrib/ldapc++/src/LDAPReferralException.h [deleted file]
contrib/ldapc++/src/LDAPSearchResults.cpp
contrib/ldapc++/src/Makefile.am
contrib/ldapc++/src/Makefile.in

index 5facda9b6f011ecb7c67daa352bffda703d032c1..2d5725c8c715f54b1b95fb210874278818161b74 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "LDAPResult.h"
 #include "LDAPException.h"
-#include "LDAPReferralException.h"
 #include "LDAPUrlList.h"
 
 #include "LDAPConnection.h"
index ce8ccc48737520155372b7b562aecf75f1fc641b..ac679203cedccc4e2182ad227b3a1f22ab0407f8 100644 (file)
@@ -8,19 +8,23 @@
 #include <ldap.h>
 #include "config.h"
 #include "LDAPException.h"
-#include "LDAPReferralException.h"
 
 #include "LDAPAsynConnection.h"
+#include "LDAPResult.h"
 
 using namespace std;
 
-LDAPException::LDAPException(int res_code, const string& err_string){
+LDAPException::LDAPException(int res_code, const string& err_string) throw()
+    : std::runtime_error(err_string)
+{
        m_res_code=res_code;
        m_res_string=string(ldap_err2string(res_code));
     m_err_string=err_string;
 }
 
-LDAPException::LDAPException(const LDAPAsynConnection *lc){
+LDAPException::LDAPException(const LDAPAsynConnection *lc) throw()
+    : 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);
@@ -43,22 +47,32 @@ LDAPException::LDAPException(const LDAPAsynConnection *lc){
     }
 }
 
-LDAPException::~LDAPException(){
+LDAPException::~LDAPException() throw()
+{
 }
 
-int LDAPException::getResultCode() const{
+int LDAPException::getResultCode() const throw()
+{
        return m_res_code;
 }
 
-const string& LDAPException::getResultMsg() const{
+const string& LDAPException::getResultMsg() const throw()
+{
        return m_res_string;
 }
 
-const string& LDAPException::getServerMsg() const{
+const string& LDAPException::getServerMsg() const throw()
+{
     return m_err_string;
 }
 
-ostream& operator << (ostream& s, LDAPException e){
+const char* LDAPException::what() const throw()
+{
+    return this->m_res_string.c_str(); 
+}
+
+ostream& operator << (ostream& s, LDAPException e) throw()
+{
        s << "Error " << e.m_res_code << ": " << e.m_res_string;
        if (!e.m_err_string.empty()) {
                s << endl <<  "additional info: " << e.m_err_string ;
@@ -66,3 +80,18 @@ ostream& operator << (ostream& s, LDAPException e){
        return s;
 }
 
+
+LDAPReferralException::LDAPReferralException(const LDAPUrlList& urls) throw() 
+        : LDAPException(LDAPResult::REFERRAL) , m_urlList(urls)
+{
+}
+
+LDAPReferralException::~LDAPReferralException() throw()
+{
+}
+
+const LDAPUrlList& LDAPReferralException::getUrls() throw()
+{
+    return m_urlList;
+}
+
index 63d813dca1478691dbb9c19cab36bb0773727932..3af993d79ea166c725c32aed01dd09ddc70d9b0d 100644 (file)
@@ -9,6 +9,9 @@
 
 #include <iostream>
 #include <string>
+#include <stdexcept>
+
+#include <LDAPUrlList.h>
 
 class LDAPAsynConnection;
 
@@ -16,7 +19,8 @@ class LDAPAsynConnection;
  * This class is only thrown as an Exception and used to signalize error
  * conditions during LDAP-operations
  */
-class LDAPException{
+class LDAPException : public std::runtime_error
+{
                
     public :
         /**
@@ -26,7 +30,7 @@ class LDAPException{
          *                      that happend (optional)
          */
         LDAPException(int res_code, 
-                const std::string& err_string=std::string());
+                const std::string& err_string=std::string()) throw();
                
         /**
          * Constructs a LDAPException-object from the error state of a
@@ -34,38 +38,69 @@ class LDAPException{
          * @param lc A LDAP-Connection for that an error has happend. The
          *          Constructor tries to read its error state.
          */
-        LDAPException(const LDAPAsynConnection *lc);
+        LDAPException(const LDAPAsynConnection *lc) throw();
 
         /**
          * Destructor
          */
-        virtual ~LDAPException();
+        virtual ~LDAPException() throw();
 
         /**
          * @return The Result code of the object
          */
-        int getResultCode() const;
+        int getResultCode() const throw();
 
         /**
          * @return The error message that is corresponding to the result
          *          code .
          */
-        const std::string& getResultMsg() const;
+        const std::string& getResultMsg() const throw();
         
         /**
          * @return The addional error message of the error (if it was set)
          */
-        const std::string& getServerMsg() const;
+        const std::string& getServerMsg() const throw();
+
+        
+        virtual const char* what() const throw();
 
         /**
          * This method can be used to dump the data of a LDAPResult-Object.
          * It is only useful for debugging purposes at the moment
          */
-        friend std::ostream& operator << (std::ostream &s, LDAPException e);
+        friend std::ostream& operator << (std::ostream &s, LDAPException e) throw();
 
     private :
         int m_res_code;
         std::string m_res_string;
         std::string m_err_string;
 };
+
+/**
+ * This class extends LDAPException and is used to signalize Referrals
+ * there were received during synchronous LDAP-operations
+ */
+class LDAPReferralException : public LDAPException
+{
+
+    public :
+        /**
+         * Creates an object that is initialized with a list of URLs
+         */
+        LDAPReferralException(const LDAPUrlList& urls) throw();
+
+        /**
+         * Destructor
+         */
+        ~LDAPReferralException() throw();
+
+        /**
+         * @return The List of URLs of the Referral/Search Reference
+         */
+        const LDAPUrlList& getUrls() throw();
+
+    private :
+        LDAPUrlList m_urlList;
+};
+
 #endif //LDAP_EXCEPTION_H
diff --git a/contrib/ldapc++/src/LDAPReferralException.cpp b/contrib/ldapc++/src/LDAPReferralException.cpp
deleted file mode 100644 (file)
index 0d05088..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-
-
-#include <iostream>
-#include "LDAPException.h"
-#include "LDAPReferralException.h"
-#include "LDAPResult.h"
-#include "LDAPRequest.h"
-#include "LDAPUrl.h"
-
-LDAPReferralException::LDAPReferralException(const LDAPUrlList& urls) : 
-        LDAPException(LDAPResult::REFERRAL) , m_urlList(urls){
-}
-
-LDAPReferralException::~LDAPReferralException(){
-}
-
-const LDAPUrlList& LDAPReferralException::getUrls(){
-    return m_urlList;
-}
-
diff --git a/contrib/ldapc++/src/LDAPReferralException.h b/contrib/ldapc++/src/LDAPReferralException.h
deleted file mode 100644 (file)
index f604f67..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-
-
-#ifndef LDAP_REFERRAL_EXCEPTION_H
-#define LDAP_REFERRAL_EXCEPTION_H
-
-#include <list>
-#include <LDAPMessage.h>
-#include <LDAPUrlList.h>
-
-class LDAPUrlList;
-
-/**
- * This class extends LDAPException and is used to signalize Referrals
- * there were received during synchronous LDAP-operations
- */
-class LDAPReferralException : public LDAPException{
-
-    public :
-        /**
-         * Creates an object that is initialized with a list of URLs
-         */
-        LDAPReferralException(const LDAPUrlList& urls);
-
-        /**
-         * Destructor
-         */
-        ~LDAPReferralException();
-
-        /**
-         * @return The List of URLs of the Referral/Search Reference
-         */
-        const LDAPUrlList& getUrls();
-
-    private :
-        LDAPUrlList m_urlList;
-};
-
-#endif //LDAP_REFERRAL_EXCEPTION_H
index 88a68989e3a38a4827c08b5ff1c0e00afd1a90ca..3fef3dcaeaf7f4775a31db8442f510139c5db45d 100644 (file)
@@ -7,7 +7,6 @@
 #include "LDAPException.h"
 #include "LDAPSearchResult.h"
 #include "LDAPResult.h"
-#include "LDAPReferralException.h"
 
 #include "LDAPSearchResults.h"
 
index 1e5cf8eebdd0778621dd97b646493563e5b02283..9e276d647a0dcabe721c348fc155eb3daa4ec3b9 100644 (file)
@@ -31,7 +31,6 @@ libldapcpp_la_SOURCES = LDAPAddRequest.cpp \
                        LDAPObjClass.cpp \
                        LDAPRebind.cpp \
                        LDAPRebindAuth.cpp \
-                       LDAPReferralException.cpp \
                        LDAPReferenceList.cpp \
                        LDAPRequest.cpp \
                        LDAPResult.cpp \
@@ -66,7 +65,6 @@ include_HEADERS = LDAPAsynConnection.h \
                        LDAPObjClass.h \
                        LDAPRebind.h \
                        LDAPRebindAuth.h \
-                       LDAPReferralException.h \
                        LDAPReferenceList.h \
                        LDAPResult.h \
                        LDAPSaslBindResult.h \
index db1433d41a7b52f6ef0e3dd6fab35d7212d5d257..c08542d99c5cf130f7f33d7f8a16705656e75848 100644 (file)
@@ -66,12 +66,11 @@ am_libldapcpp_la_OBJECTS = LDAPAddRequest.lo LDAPAsynConnection.lo \
        LDAPMessage.lo LDAPMessageQueue.lo LDAPModDNRequest.lo \
        LDAPModification.lo LDAPModifyRequest.lo LDAPModList.lo \
        LDAPObjClass.lo LDAPRebind.lo LDAPRebindAuth.lo \
-       LDAPReferralException.lo LDAPReferenceList.lo LDAPRequest.lo \
-       LDAPResult.lo LDAPSaslBindResult.lo LDAPSchema.lo \
-       LDAPSearchReference.lo LDAPSearchRequest.lo \
-       LDAPSearchResult.lo LDAPSearchResults.lo LDAPUrl.lo \
-       LDAPUrlList.lo SaslInteraction.lo SaslInteractionHandler.lo \
-       StringList.lo
+       LDAPReferenceList.lo LDAPRequest.lo LDAPResult.lo \
+       LDAPSaslBindResult.lo LDAPSchema.lo LDAPSearchReference.lo \
+       LDAPSearchRequest.lo LDAPSearchResult.lo LDAPSearchResults.lo \
+       LDAPUrl.lo LDAPUrlList.lo SaslInteraction.lo \
+       SaslInteractionHandler.lo StringList.lo
 libldapcpp_la_OBJECTS = $(am_libldapcpp_la_OBJECTS)
 libldapcpp_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
@@ -228,7 +227,6 @@ libldapcpp_la_SOURCES = LDAPAddRequest.cpp \
                        LDAPObjClass.cpp \
                        LDAPRebind.cpp \
                        LDAPRebindAuth.cpp \
-                       LDAPReferralException.cpp \
                        LDAPReferenceList.cpp \
                        LDAPRequest.cpp \
                        LDAPResult.cpp \
@@ -263,7 +261,6 @@ include_HEADERS = LDAPAsynConnection.h \
                        LDAPObjClass.h \
                        LDAPRebind.h \
                        LDAPRebindAuth.h \
-                       LDAPReferralException.h \
                        LDAPReferenceList.h \
                        LDAPResult.h \
                        LDAPSaslBindResult.h \
@@ -403,7 +400,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPRebind.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPRebindAuth.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPReferenceList.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPReferralException.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPRequest.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPResult.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPSaslBindResult.Plo@am__quote@