Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions
In directory sc8-pr-cvs1:/tmp/cvs-serv22602/src/exceptions
Modified Files:
Exception.h ThreadException.cpp ThreadException.h
Exception.cpp
Log Message:
24/12/2003 Barbeaux
* Implemented Mutex and Condition.
* Implemented a ThreadException.
* Added origin message into Exception handler.
Index: Exception.h
===================================================================
RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/Exception.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Exception.h 24 Dec 2003 10:49:48 -0000 1.1
+++ Exception.h 24 Dec 2003 11:52:49 -0000 1.2
@@ -35,6 +35,8 @@
// code of this exception
int code;
+ // origin of this exception
+ string origin;
public:
@@ -43,8 +45,14 @@
*
* @param eCode - code number of this exception
* @param message - A message to explain this exception
+ * @param origin - Method of throw the exception
*/
- explicit Exception(int eCode, const string& message);
+ explicit Exception(int eCode, const string& message, const string& origin);
+
+ /**
+ * Destructor for Exception
+ */
+ virtual ~Exception() throw() {}
/**
* Returns the error code of this exception
Index: ThreadException.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/ThreadException.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ThreadException.cpp 24 Dec 2003 10:49:48 -0000 1.1
+++ ThreadException.cpp 24 Dec 2003 11:52:49 -0000 1.2
@@ -25,8 +25,8 @@
* Creates a ThreadException object with the given error code and
* message.
*/
-ThreadException::ThreadException(ThreadError eCode, const string& message) :
- Exception(eCode, message) {
+ThreadException::ThreadException(ThreadError eCode, const string& message,
+ const string& origin) : Exception(eCode, message, origin) {
}
/**
@@ -36,6 +36,9 @@
const string ThreadException::getMessage() const {
ostringstream message;
// Build error message depending error code
+ message << "-----------------------" << endl;
+ message << "WARNING : Exception thrown !!" << endl;
+ message << "| Type : ";
switch(code) {
case MutexError:
message << "MutexError";
@@ -44,8 +47,9 @@
message << "UnknownError";
break;
}
- message << ": ";
- message << what();
+ message << endl << "| From : " << origin << endl;
+ message << "| Message : " << what() << endl;
+ message << "-----------------------" << endl;
return message.str();
}
Index: ThreadException.h
===================================================================
RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/ThreadException.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ThreadException.h 24 Dec 2003 10:49:48 -0000 1.1
+++ ThreadException.h 24 Dec 2003 11:52:49 -0000 1.2
@@ -23,7 +23,8 @@
#include "Exception.h"
enum ThreadError {
- MutexError
+ MutexError,
+ ConditionError
};
/**
@@ -38,8 +39,10 @@
*
* @param eCode - code of this exception
* @param message - Message to send to this exception
+ * @param origin - Method who throws the exception
*/
- ThreadException(ThreadError eCode, const string& message);
+ ThreadException(ThreadError eCode, const string& message,
+ const string& origin);
/**
* Returns the message sent by this Thread exception.
Index: Exception.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/Exception.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Exception.cpp 24 Dec 2003 10:49:48 -0000 1.1
+++ Exception.cpp 24 Dec 2003 11:52:49 -0000 1.2
@@ -23,8 +23,8 @@
* Creates a Exception object with the given code and
* message.
*/
-Exception::Exception(int eCode, const string& message) :
- runtime_error(message), code(eCode) {
+Exception::Exception(int eCode, const string& message, const string& origin) :
+ runtime_error(message), code(eCode), origin(origin) {
}
/**
|