Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Exceptions.h

00001 #ifndef  EDG_WORKLOAD_COMMON_CLIENT_EXCEPTIONS_H
00002 #define EDG_WORKLOAD_COMMON_CLIENT_EXCEPTIONS_H
00003 
00004 /*
00005  * Exceptions.h
00006  * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved.
00007  * Contributors are mentioned in the code where appropriate.
00008  */
00009 
00010 #include <fstream>
00011 #include <cstdlib>
00012 //#include <list>
00013 #include <syslog.h>  // For logging exceptions to log file
00014 #include <errno.h> // list the exception codes
00015 #include <string>
00016 #include <exception> // base ancestor
00017 #include "edg/workload/common/utilities/result_codes.h" //base result codes
00018 #include "edg/workload/common/common_namespace.h" // base namespace
00019 COMMON_NAMESPACE_BEGIN{
00020      namespace utilities {
00021 extern pthread_mutex_t METHOD_MUTEX; //  used in order to store info into a file (rather then syslog)
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         //Mandatory Information:
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         // Exception* exc ;
00122 }; //End  Exception Class
00123 
00127 class FatalErrorException : public Exception {
00128 public:
00129     FatalErrorException(const std::string& file,
00130                         int line,
00131                         const std::string& method);
00132 };//End CLass      FatalErrorException
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 };//End CLass   StdException
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 };//End CLass   StdException
00157 
00158 // EWC_END_NAMESPACE; //Close the NameSpace
00159 } COMMON_NAMESPACE_END
00160 }
00161 
00162 #endif

Generated on Fri May 14 14:18:25 2004 for COMMON API - configuration, jobid, ldif2classadi, logger, process, requestad, socket++i, task, utilities by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002