00001 #ifndef __EDG_WORKLOAD_LOGGING_CLIENT_LOGGING_EXCEPTIONS_H
00002 #define __EDG_WORKLOAD_LOGGING_CLIENT_LOGGING_EXCEPTIONS_H
00003
00004 #include "edg/workload/common/utilities/Exceptions.h"
00005
00006 #include <pthread.h>
00007
00008 #ident "$Header: /local/reps/lcgware/workload/logging/client/LoggingExceptions.h,v 1.8 2003/05/23 13:40:39 michal Exp $"
00009
00014 EWL_BEGIN_NAMESPACE;
00015
00016 class Exception: public edg::workload::common::utilities::Exception {
00017 public:
00018
00019
00020 Exception(const std::string& source,
00021 int line_number,
00022 const std::string& method,
00023 int code,
00024 const std::string& exception)
00025 : edg::workload::common::utilities::Exception(source,
00026 line_number,
00027 method,
00028 code,
00029 "edg::workload::logging::Exception")
00030 { error_message = exception; };
00031
00032
00033 Exception(const std::string& source,
00034 int line_number,
00035 const std::string& method,
00036 int code,
00037 const std::string& exception,
00038 const edg::workload::common::utilities::Exception &exc)
00039 : edg::workload::common::utilities::Exception(source,
00040 line_number,
00041 method,
00042 code,
00043 "edg::workload::logging::Exception")
00044 { error_message = exception + ": " + exc.what(); };
00045 };
00046
00047
00048 class LoggingException: public Exception {
00049 public:
00050
00051
00052 LoggingException(const std::string& source,
00053 int line_number,
00054 const std::string& method,
00055 int code,
00056 const std::string& exception)
00057 : Exception(source, line_number, method, code, exception)
00058 {};
00059
00060
00061 LoggingException(const std::string& source,
00062 int line_number,
00063 const std::string& method,
00064 int code,
00065 const std::string& exception,
00066 const edg::workload::common::utilities::Exception &exc)
00067 : Exception(source, line_number, method, code, exception)
00068 {};
00069 };
00070
00071
00072 class OSException: public Exception {
00073 public:
00074
00075
00076 OSException(const std::string& source,
00077 int line_number,
00078 const std::string& method,
00079 int code,
00080 const std::string& exception)
00081 : Exception(source,
00082 line_number,
00083 method,
00084 code,
00085 exception + ": " + strerror(code))
00086 {};
00087
00088
00089 OSException(const std::string& source,
00090 int line_number,
00091 const std::string& method,
00092 int code,
00093 const std::string& exception,
00094 const edg::workload::common::utilities::Exception &exc)
00095 : Exception(source,
00096 line_number,
00097 method,
00098 code,
00099 exception + ": " + strerror(code))
00100 {};
00101 };
00102
00103
00104 #define EXCEPTION_MANDATORY \
00105 __FILE__, \
00106 __LINE__, \
00107 std::string(CLASS_PREFIX) + __FUNCTION__
00108
00109 #define STACK_ADD
00110
00111
00112 #define throw_exception(context, exception) \
00113 { STACK_ADD; \
00114 { \
00115 char *text, *desc; \
00116 int code; \
00117 std::string exc; \
00118 \
00119 code = edg_wll_Error((context), &text, &desc); \
00120 exc = exception; \
00121 if (text) { \
00122 exc += ": "; \
00123 exc += text; \
00124 } \
00125 if (desc) { \
00126 exc += ": "; \
00127 exc += desc; \
00128 } \
00129 free(text); \
00130 free(desc); \
00131 throw LoggingException(EXCEPTION_MANDATORY, \
00132 code, \
00133 exc); \
00134 } \
00135 }
00136
00137 #define check_result(code, context, desc) \
00138 if((code)) throw_exception((context), desc)
00139
00140
00141
00142 EWL_END_NAMESPACE;
00143
00144 #endif