Thrift-1334: Add more info to IllegalStateException
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
diff --git a/lib/cpp/src/concurrency/Exception.h b/lib/cpp/src/concurrency/Exception.h
index ec46629..06ba0d3 100644
--- a/lib/cpp/src/concurrency/Exception.h
+++ b/lib/cpp/src/concurrency/Exception.h
@@ -31,7 +31,11 @@
 
 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:
diff --git a/lib/cpp/src/concurrency/ThreadManager.cpp b/lib/cpp/src/concurrency/ThreadManager.cpp
index f7b2690..e56a9b5 100644
--- a/lib/cpp/src/concurrency/ThreadManager.cpp
+++ b/lib/cpp/src/concurrency/ThreadManager.cpp
@@ -467,7 +467,8 @@
     }
 
     if (state_ != ThreadManager::STARTED) {
-      throw IllegalStateException();
+      throw IllegalStateException("ThreadManager::Impl::add ThreadManager "
+                                  "not started");
     }
 
     removeExpiredTasks();
@@ -495,14 +496,16 @@
   (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()) {