00001 #ifndef EDG_WORKLOAD_COMMON_CLIENT_EXCEPTIONS_H
00002 #define EDG_WORKLOAD_COMMON_CLIENT_EXCEPTIONS_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <fstream>
00011 #include <cstdlib>
00012
00013 #include <syslog.h>
00014 #include <errno.h>
00015 #include <string>
00016 #include <exception>
00017 #include "edg/workload/common/utilities/result_codes.h"
00018 #include "edg/workload/common/common_namespace.h"
00019 COMMON_NAMESPACE_BEGIN{
00020 namespace utilities {
00021 extern pthread_mutex_t METHOD_MUTEX;
00022 #define EDG_STACK_TRY(method_name) std::string METHOD = method_name ; try {
00023 #define EDG_STACK_CATCH() } catch (edg::workload::common::utilities::Exception &exc){ throw edg::workload::common::utilities::Exception ( __FILE__ , METHOD , &exc) ; }
00024
00044 class Exception : public std::exception{
00045 public:
00046 Exception ( const std::string& source,
00047 const std::string& method,
00048 Exception *e);
00057 Exception ( const std::string& source,
00058 const std::string& method,
00059 int code,
00060 const std::string& exception);
00061
00069 Exception (const std::string& source,
00070 int line_number,
00071 const std::string& method,
00072 int code,
00073 const std::string& exception);
00074
00078 virtual ~Exception() throw ();
00082 virtual std::string dbgMessage();
00086 virtual int getCode();
00087
00091 virtual const char* what() const throw ();
00092
00096 virtual void log(const std::string& logfile = "");
00100 virtual std::string getExceptionName();
00101
00105 virtual std::string printStackTrace() ;
00106
00107 protected:
00111 Exception();
00112
00113 int error_code;
00114 std::string error_message ;
00115 int line;
00116 std::string source_file;
00117 std::string exception_name;
00118 std::string method_name ;
00119 std::string stack;
00120 std::string ancestor ;
00121
00122 };
00123
00127 class FatalErrorException : public Exception {
00128 public:
00129 FatalErrorException(const std::string& file,
00130 int line,
00131 const std::string& method);
00132 };
00133
00137 class StdException : public Exception {
00138 public:
00139 StdException(const std::string& file,
00140 int line,
00141 const std::string& method,
00142 int code,
00143 const std::string& exception_name);
00144 };
00145
00149 class ThreadException : public Exception {
00150 public:
00151 ThreadException(const std::string& file,
00152 int line,
00153 const std::string& method,
00154 int code,
00155 int jobNumber);
00156 };
00157
00158
00159 } COMMON_NAMESPACE_END
00160 }
00161
00162 #endif