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/Attic/LoggingExceptions.h,v 1.6.22.1 2010/03/16 09:12:22 zsustr Exp $"
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00027 #include "glite/wmsutils/exception/Exception.h"
00028
00029 #include <pthread.h>
00030
00031 EWL_BEGIN_NAMESPACE
00032
00043 class Exception: public glite::wmsutils::exception::Exception {
00044 public:
00045
00055 Exception(const std::string& source,
00056 int line_number,
00057 const std::string& method,
00058 int code,
00059 const std::string& exception)
00060 : glite::wmsutils::exception::Exception(source,
00061 line_number,
00062 method,
00063 code,
00064 "glite::lb::Exception")
00065 { error_message = exception; };
00066
00079 Exception(const std::string& source,
00080 int line_number,
00081 const std::string& method,
00082 int code,
00083 const std::string& exception,
00084 const glite::wmsutils::exception::Exception &exc)
00085 : glite::wmsutils::exception::Exception(source,
00086 line_number,
00087 method,
00088 code,
00089 "glite::lb::Exception")
00090 { error_message = exception + ": " + exc.what(); };
00091 };
00092
00093
00101 class LoggingException: public Exception {
00102 public:
00103
00113 LoggingException(const std::string& source,
00114 int line_number,
00115 const std::string& method,
00116 int code,
00117 const std::string& exception)
00118 : Exception(source, line_number, method, code, exception)
00119 {};
00120
00133 LoggingException(const std::string& source,
00134 int line_number,
00135 const std::string& method,
00136 int code,
00137 const std::string& exception,
00138 const glite::wmsutils::exception::Exception &exc)
00139 : Exception(source, line_number, method, code, exception)
00140 {};
00141 };
00142
00143
00150 class OSException: public Exception {
00151 public:
00152
00162 OSException(const std::string& source,
00163 int line_number,
00164 const std::string& method,
00165 int code,
00166 const std::string& exception)
00167 : Exception(source,
00168 line_number,
00169 method,
00170 code,
00171 exception + ": " + strerror(code))
00172 {};
00173
00186 OSException(const std::string& source,
00187 int line_number,
00188 const std::string& method,
00189 int code,
00190 const std::string& exception,
00191 const glite::wmsutils::exception::Exception &exc)
00192 : Exception(source,
00193 line_number,
00194 method,
00195 code,
00196 exception + ": " + strerror(code))
00197 {};
00198 };
00199
00200
00206 #define EXCEPTION_MANDATORY \
00207 __FILE__, \
00208 __LINE__, \
00209 std::string(CLASS_PREFIX) + __FUNCTION__
00210
00217 #define STACK_ADD
00218
00226 #define throw_exception(context, exception) \
00227 { STACK_ADD; \
00228 { \
00229 char *text, *desc; \
00230 int code; \
00231 std::string exc; \
00232 \
00233 code = edg_wll_Error((context), &text, &desc); \
00234 exc = exception; \
00235 if (text) { \
00236 exc += ": "; \
00237 exc += text; \
00238 } \
00239 if (desc) { \
00240 exc += ": "; \
00241 exc += desc; \
00242 } \
00243 free(text); \
00244 free(desc); \
00245 throw LoggingException(EXCEPTION_MANDATORY, \
00246 code, \
00247 exc); \
00248 } \
00249 }
00250
00256 #define check_result(code, context, desc) \
00257 if((code)) throw_exception((context), desc)
00258
00259
00260
00261 EWL_END_NAMESPACE
00262
00263 #endif