00001 // $Id: TDbiException.cxx,v 1.1 2011/01/18 05:49:19 finch Exp $ 00002 00003 00004 #include <iostream> 00005 00006 #include "TSQLServer.h" 00007 #include "TSQLStatement.h" 00008 00009 #include "TDbiException.hxx" 00010 #include <TSK_DBI_Log.hxx> 00011 #include <MsgFormat.h> 00012 using std::endl; 00013 00014 ClassImp(TDbiException) 00015 00016 // Definition of static data members 00017 // ********************************* 00018 00019 00020 // Definition of all member functions (static or otherwise) 00021 // ******************************************************* 00022 // 00023 // - ordered: ctors, dtor, operators then in alphabetical order. 00024 00025 //..................................................................... 00026 00027 /// Create an exception using the msg and code provided. 00028 TDbiException::TDbiException(const char* msg /*= 0*/, 00029 Int_t code /* = -1 */): 00030 fMessage(msg), 00031 fErrorCode(code) 00032 { 00033 00034 SK_DBI_Trace( "Creating TDbiException" << " "); 00035 00036 } 00037 00038 //..................................................................... 00039 /// Create an exception, getting the error message and code from server. 00040 TDbiException::TDbiException(const TSQLServer& server): 00041 fMessage(server.GetErrorMsg()), 00042 fErrorCode(server.GetErrorCode()) 00043 { 00044 00045 SK_DBI_Trace( "Creating TDbiException" << " "); 00046 00047 } 00048 00049 //..................................................................... 00050 /// Create and exception, taking the message and code from statement. 00051 TDbiException::TDbiException(const TSQLStatement& statement): 00052 fMessage(statement.GetErrorMsg()), 00053 fErrorCode(statement.GetErrorCode()) 00054 { 00055 00056 SK_DBI_Trace( "Creating TDbiException" << " "); 00057 00058 } 00059 00060 //..................................................................... 00061 00062 00063 TDbiException::TDbiException(const TDbiException& that) 00064 { 00065 00066 SK_DBI_Trace( "Creating TDbiException" << " "); 00067 00068 *this = that; 00069 00070 } 00071 00072 //..................................................................... 00073 00074 00075 TDbiException::~TDbiException() { 00076 00077 00078 SK_DBI_Trace( "Destroying TDbiException" << " "); 00079 00080 } 00081 00082 //..................................................................... 00083 /// Append message describing this exception to the std::ostream 'os'. 00084 std::ostream& operator<<(std::ostream& os, const TDbiException& e) { 00085 00086 os << "Error " << e.GetErrorCode() 00087 << " (" << e.GetMessage() << ")" << endl; 00088 return os; 00089 00090 } 00091