00001 /* -*- C++ -*- 00002 * 00003 * ReplicationExceptions.h 00004 * 00005 * Copyright (c) 2002 CERN on behalf of the EU DataGrid. 00006 * For license conditions see LICENSE file or 00007 * http://www.edg.org/license.html 00008 * 00009 */ 00010 00011 #include <exception> 00012 #include <string> 00013 00014 #ifndef ROSReplicationExceptions_H 00015 #define ROSReplicationExceptions_H 1 00016 00023 namespace EdgReplicaOptimization { 00024 00029 class ReplicationException : public std::exception { 00030 public: 00031 00032 public: 00033 ReplicationException() throw() 00034 : m_faultCode("FAULTABLE") { 00035 } 00036 ReplicationException(const std::string& what) throw() 00037 : m_what (what), m_faultCode("INTERNAL") { 00038 } 00039 ReplicationException(const std::string& what, 00040 const std::string& faultCode) throw() 00041 : m_what (what), m_faultCode(faultCode) { 00042 } 00043 const std::string& faultCode() const throw() { 00044 return m_faultCode; 00045 } 00046 virtual const char* what () const throw() { 00047 return m_what.c_str (); 00048 } 00049 virtual ~ReplicationException() throw(){ 00050 } 00051 00052 private: 00053 std::string m_what; 00054 std::string m_faultCode; 00055 00056 }; 00057 00058 00059 class CommunicationException : public ReplicationException { 00060 public: 00061 CommunicationException() 00062 : ReplicationException() { 00063 } 00064 CommunicationException(const std::string& message) 00065 : ReplicationException(message, "CONNECTION") { 00066 } 00067 virtual ~CommunicationException() throw(){ 00068 } 00069 }; 00070 00076 void 00077 throwReplicationException(const std::string& fault, 00078 const std::string& detail); 00079 } 00080 00081 00082 #endif // ReplicationExceptions_H 00083