Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members

LoggingExceptions.h

Go to the documentation of this file.
00001 #ifndef __EDG_WORKLOAD_LOGGING_CLIENT_LOGGING_EXCEPTIONS_HPP__
00002 #define __EDG_WORKLOAD_LOGGING_CLIENT_LOGGING_EXCEPTIONS_HPP__
00003 
00004 #ident "$Header: /cvs/glite/org.glite.lb.client-interface/interface/LoggingExceptions.h,v 1.6 2005/08/03 09:30:10 akrenek Exp $"
00005 
00010 #include "glite/wmsutils/exception/Exception.h"
00011 
00012 #include <pthread.h>
00013 
00014 EWL_BEGIN_NAMESPACE
00015 
00026 class Exception: public glite::wmsutils::exception::Exception {
00027 public:
00028         
00038         Exception(const std::string& source,
00039                   int line_number,
00040                   const std::string& method,
00041                   int   code,
00042                   const std::string& exception) 
00043                 : glite::wmsutils::exception::Exception(source, 
00044                                                         line_number, 
00045                                                         method, 
00046                                                         code, 
00047                                                         "glite::lb::Exception")
00048                 { error_message = exception; };
00049         
00062         Exception(const std::string& source,
00063                   int line_number,
00064                   const std::string& method,
00065                   int   code,
00066                   const std::string& exception,
00067                   const glite::wmsutils::exception::Exception &exc)
00068                 : glite::wmsutils::exception::Exception(source, 
00069                                                         line_number, 
00070                                                         method, 
00071                                                         code, 
00072                                                         "glite::lb::Exception")
00073                 { error_message = exception + ": " + exc.what(); };
00074 };
00075 
00076 
00084 class LoggingException: public Exception {
00085 public:
00086         
00096         LoggingException(const std::string& source,
00097                          int line_number,
00098                          const std::string& method,
00099                          int   code,
00100                          const std::string& exception) 
00101                 : Exception(source, line_number, method, code, exception)
00102                 {};
00103         
00116         LoggingException(const std::string& source,
00117                          int line_number,
00118                          const std::string& method,
00119                          int   code,
00120                          const std::string& exception, 
00121                          const glite::wmsutils::exception::Exception &exc)
00122                 : Exception(source, line_number, method, code, exception)
00123                 {};
00124 };
00125 
00126 
00133 class OSException: public Exception {
00134 public:
00135         
00145         OSException(const std::string& source,
00146                     int line_number,
00147                     const std::string& method,
00148                     int   code,
00149                     const std::string& exception)
00150                 : Exception(source, 
00151                             line_number, 
00152                             method, 
00153                             code, 
00154                             exception + ": " + strerror(code))
00155                 {};
00156         
00169         OSException(const std::string& source,
00170                     int line_number,
00171                     const std::string& method,
00172                     int   code,
00173                     const std::string& exception,
00174                     const glite::wmsutils::exception::Exception &exc)
00175                 : Exception(source, 
00176                             line_number, 
00177                             method, 
00178                             code, 
00179                             exception + ": " + strerror(code))
00180                 {};
00181 };
00182 
00183 
00189 #define EXCEPTION_MANDATORY                           \
00190         __FILE__,                                     \
00191         __LINE__,                                     \
00192         std::string(CLASS_PREFIX) + __FUNCTION__         
00193 
00200 #define STACK_ADD                                     
00201 
00209 #define throw_exception(context, exception)           \
00210 { STACK_ADD;                                          \
00211   {                                                   \
00212      char *text, *desc;                               \
00213      int  code;                                       \
00214      std::string exc;                                      \
00215                                                       \
00216      code = edg_wll_Error((context), &text, &desc);   \
00217      exc = exception;                                 \
00218      if (text) {                                      \
00219         exc += ": ";                                  \
00220         exc += text;                                  \
00221      }                                                \
00222      if (desc) {                                      \
00223         exc += ": ";                                  \
00224         exc += desc;                                  \
00225      }                                                \
00226      free(text);                                      \
00227      free(desc);                                      \
00228      throw LoggingException(EXCEPTION_MANDATORY,      \
00229                             code,                     \
00230                             exc);                     \
00231   }                                                   \
00232 }
00233  
00239 #define check_result(code, context, desc)             \
00240   if((code)) throw_exception((context), desc)
00241 
00242 
00243 
00244 EWL_END_NAMESPACE
00245 
00246 #endif

Generated on Wed Jun 27 13:43:06 2007 for Glite LB Client: CPP - Interface by doxygen 1.3.5