From 4013fa3117546536bc21f469100e144f20d50f01 Mon Sep 17 00:00:00 2001 From: Jake Farrell Date: Fri, 9 Sep 2011 04:10:32 +0000 Subject: [PATCH] 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 --- lib/cpp/src/concurrency/Exception.h | 6 +++++- lib/cpp/src/concurrency/ThreadManager.cpp | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/cpp/src/concurrency/Exception.h b/lib/cpp/src/concurrency/Exception.h index ec466297..06ba0d3d 100644 --- a/lib/cpp/src/concurrency/Exception.h +++ b/lib/cpp/src/concurrency/Exception.h @@ -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: diff --git a/lib/cpp/src/concurrency/ThreadManager.cpp b/lib/cpp/src/concurrency/ThreadManager.cpp index f7b26901..e56a9b5f 100644 --- a/lib/cpp/src/concurrency/ThreadManager.cpp +++ b/lib/cpp/src/concurrency/ThreadManager.cpp @@ -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 task) { (void) task; Synchronized s(monitor_); if (state_ != ThreadManager::STARTED) { - throw IllegalStateException(); + throw IllegalStateException("ThreadManager::Impl::remove ThreadManager not " + "started"); } } boost::shared_ptr ThreadManager::Impl::removeNextPending() { Guard g(mutex_); if (state_ != ThreadManager::STARTED) { - throw IllegalStateException(); + throw IllegalStateException("ThreadManager::Impl::removeNextPending " + "ThreadManager not started"); } if (tasks_.empty()) { -- 2.17.1