Thrift-1334: Add more info to IllegalStateException
authorJake Farrell <jfarrell@apache.org>
Fri, 9 Sep 2011 04:10:32 +0000 (04:10 +0000)
committerJake Farrell <jfarrell@apache.org>
Fri, 9 Sep 2011 04:10:32 +0000 (04:10 +0000)
Client cpp
Patch: Dave Watson

Add support for the message field in IllegalStateException

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1166992 13f79535-47bb-0310-9956-ffa450edef68

lib/cpp/src/concurrency/Exception.h
lib/cpp/src/concurrency/ThreadManager.cpp

index ec46629..06ba0d3 100644 (file)
@@ -31,7 +31,11 @@ class UncancellableTaskException : public apache::thrift::TException {};
 
 class InvalidArgumentException : public apache::thrift::TException {};
 
-class IllegalStateException : public apache::thrift::TException {};
+class IllegalStateException : public apache::thrift::TException {
+public:
+  IllegalStateException() {}
+  IllegalStateException(const std::string& message) : TException(message) {}
+};
 
 class TimedOutException : public apache::thrift::TException {
 public:
index f7b2690..e56a9b5 100644 (file)
@@ -467,7 +467,8 @@ void ThreadManager::Impl::removeWorker(size_t value) {
     }
 
     if (state_ != ThreadManager::STARTED) {
-      throw IllegalStateException();
+      throw IllegalStateException("ThreadManager::Impl::add ThreadManager "
+                                  "not started");
     }
 
     removeExpiredTasks();
@@ -495,14 +496,16 @@ void ThreadManager::Impl::remove(shared_ptr<Runnable> task) {
   (void) task;
   Synchronized s(monitor_);
   if (state_ != ThreadManager::STARTED) {
-    throw IllegalStateException();
+    throw IllegalStateException("ThreadManager::Impl::remove ThreadManager not "
+                                "started");
   }
 }
 
 boost::shared_ptr<Runnable> ThreadManager::Impl::removeNextPending() {
   Guard g(mutex_);
   if (state_ != ThreadManager::STARTED) {
-    throw IllegalStateException();
+    throw IllegalStateException("ThreadManager::Impl::removeNextPending "
+                                "ThreadManager not started");
   }
 
   if (tasks_.empty()) {