* Cleaned up the exception classes so they require less space. This

reduced the size of the stripped libtorrent by 1/7.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@822 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-12-11 10:33:09 +00:00
parent 460aac5df0
commit fcb8154188
26 changed files with 97 additions and 97 deletions
+3 -3
View File
@@ -101,7 +101,7 @@ DownloadFactory::commit() {
void
DownloadFactory::receive_load() {
if (m_stream)
throw torrent::client_error("DownloadFactory::load() called on an object with m_stream != NULL");
throw torrent::internal_error("DownloadFactory::load() called on an object with m_stream != NULL");
if (std::strncmp(m_uri.c_str(), "http://", 7) == 0) {
// Http handling here.
@@ -143,7 +143,7 @@ DownloadFactory::receive_commit() {
void
DownloadFactory::receive_success() {
if (m_stream == NULL)
throw torrent::client_error("DownloadFactory::receive_success() called on an object with m_stream == NULL.");
throw torrent::internal_error("DownloadFactory::receive_success() called on an object with m_stream == NULL.");
Download* download = m_manager->download_list()->create(m_stream, m_printLog);
@@ -252,7 +252,7 @@ DownloadFactory::receive_success() {
void
DownloadFactory::receive_failed(const std::string& msg) {
if (m_stream == NULL)
throw torrent::client_error("DownloadFactory::receive_success() called on an object with m_stream == NULL");
throw torrent::internal_error("DownloadFactory::receive_success() called on an object with m_stream == NULL");
// Add message to log.
if (m_printLog) {
+7 -7
View File
@@ -60,7 +60,7 @@ inline void
DownloadList::check_contains(Download* d) {
#ifdef USE_EXTRA_DEBUG
if (std::find(begin(), end(), d) == end())
throw torrent::client_error("DownloadList::check_contains(...) failed.");
throw torrent::internal_error("DownloadList::check_contains(...) failed.");
#endif
}
@@ -128,7 +128,7 @@ DownloadList::insert(Download* download) {
} catch (torrent::local_error& e) {
// Should perhaps relax this, just print an error and remove the
// downloads?
throw torrent::client_error("Caught during DownloadList::insert(...): " + std::string(e.what()));
throw torrent::internal_error("Caught during DownloadList::insert(...): " + std::string(e.what()));
}
return itr;
@@ -144,7 +144,7 @@ DownloadList::erase(Download* download) {
DownloadList::iterator
DownloadList::erase(iterator itr) {
if (itr == end())
throw torrent::client_error("DownloadList::erase(...) could not find download.");
throw torrent::internal_error("DownloadList::erase(...) could not find download.");
// Makes sure close doesn't restart hashing of this download.
(*itr)->set_hash_failed(true);
@@ -223,7 +223,7 @@ DownloadList::close_throw(Download* download) {
download->download()->close();
if (!download->is_hash_failed() && download->variable()->get_value("hashing") != Download::variable_hashing_stopped)
throw torrent::client_error("DownloadList::close_throw(...) called but we're going into a hashing loop.");
throw torrent::internal_error("DownloadList::close_throw(...) called but we're going into a hashing loop.");
std::for_each(slot_map_hash_removed().begin(), slot_map_hash_removed().end(), download_list_call(download));
std::for_each(slot_map_close().begin(), slot_map_close().end(), download_list_call(download));
@@ -391,10 +391,10 @@ DownloadList::hash_done(Download* download) {
check_contains(download);
if (!download->is_open())
throw torrent::client_error("DownloadList::hash_done(...) !download->is_open().");
throw torrent::internal_error("DownloadList::hash_done(...) !download->is_open().");
if (download->is_hash_checking() || download->is_active())
throw torrent::client_error("DownloadList::hash_done(...) download in invalid state.");
throw torrent::internal_error("DownloadList::hash_done(...) download in invalid state.");
if (!download->is_hash_checked()) {
download->set_hash_failed(true);
@@ -463,7 +463,7 @@ DownloadList::hash_queue(Download* download, int type) {
check_contains(download);
if (download->variable()->get_value("hashing") != Download::variable_hashing_stopped)
throw torrent::client_error("DownloadList::hash_queue(...) hashing already queued.");
throw torrent::internal_error("DownloadList::hash_queue(...) hashing already queued.");
close_throw(download);
torrent::resume_clear_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
+3 -3
View File
@@ -204,7 +204,7 @@ Manager::~Manager() {
void
Manager::set_hashing_view(View* v) {
if (v == NULL || m_hashingView != NULL)
throw torrent::client_error("Manager::set_hashing_view(...) received NULL or is already set.");
throw torrent::internal_error("Manager::set_hashing_view(...) received NULL or is already set.");
m_hashingView = v;
v->signal_changed().connect(sigc::mem_fun(this, &Manager::receive_hashing_changed));
@@ -501,7 +501,7 @@ Manager::receive_hashing_changed() {
}
if ((*itr)->is_hash_checked())
throw torrent::client_error("core::Manager::receive_hashing_changed() hash already checked or checking.");
throw torrent::internal_error("core::Manager::receive_hashing_changed() hash already checked or checking.");
if ((*itr)->is_hash_failed() || (*itr)->variable()->get_value("hashing") != Download::variable_hashing_initial)
continue;
@@ -533,7 +533,7 @@ Manager::receive_hashing_changed() {
try {
if ((*itr)->is_hash_checked() || (*itr)->is_hash_checking())
throw torrent::client_error("core::Manager::receive_hashing_changed() hash already checked or checking.");
throw torrent::internal_error("core::Manager::receive_hashing_changed() hash already checked or checking.");
if ((*itr)->is_hash_failed())
continue;
+2 -2
View File
@@ -82,7 +82,7 @@ Scheduler::update() {
for (View::iterator itr = m_view->begin_visible(), last = m_view->end_visible(); curActive > target; ++itr) {
if (itr == last)
throw torrent::client_error("Scheduler::update() loop bork.");
throw torrent::internal_error("Scheduler::update() loop bork.");
if ((*itr)->is_active()) {
m_downloadList->pause(*itr);
@@ -94,7 +94,7 @@ Scheduler::update() {
for (View::iterator itr = m_view->begin_visible(), last = m_view->end_visible(); curActive < m_maxActive; ++itr) {
if (itr == last)
throw torrent::client_error("Scheduler::update() loop bork.");
throw torrent::internal_error("Scheduler::update() loop bork.");
if (!(*itr)->is_active()) {
m_downloadList->start_try(*itr);
+8 -8
View File
@@ -59,15 +59,15 @@ View::~View() {
void
View::initialize(const std::string& name, core::DownloadList* dlist) {
if (!m_name.empty())
throw torrent::client_error("View::initialize(...) called on an already initialized view.");
throw torrent::internal_error("View::initialize(...) called on an already initialized view.");
if (name.empty())
throw torrent::client_error("View::initialize(...) called with an empty name.");
throw torrent::internal_error("View::initialize(...) called with an empty name.");
std::string key = "0_view_" + name;
if (dlist->has_slot_insert(key) || dlist->has_slot_erase(key))
throw torrent::client_error("View::initialize(...) duplicate key name found in DownloadList.");
throw torrent::internal_error("View::initialize(...) duplicate key name found in DownloadList.");
m_name = name;
m_list = dlist;
@@ -166,7 +166,7 @@ View::filter() {
void
View::set_filter_on(int event) {
if (event == DownloadList::SLOTS_INSERT || event == DownloadList::SLOTS_ERASE || event >= DownloadList::SLOTS_MAX_SIZE)
throw torrent::client_error("View::filter_on(...) invalid event.");
throw torrent::internal_error("View::filter_on(...) invalid event.");
m_list->slots(event)["0_view_" + m_name] = sigc::bind(sigc::mem_fun(this, &View::received), event);
}
@@ -191,7 +191,7 @@ View::insert_visible(Download* d) {
inline void
View::erase(iterator itr) {
if (itr == end_filtered())
throw torrent::client_error("View::erase_visible(...) iterator out of range.");
throw torrent::internal_error("View::erase_visible(...) iterator out of range.");
m_size -= (itr < end_visible());
m_focus -= (m_focus > position(itr));
@@ -207,7 +207,7 @@ View::received(core::Download* download, int event) {
case DownloadList::SLOTS_INSERT:
if (itr != base_type::end())
throw torrent::client_error("View::received(..., SLOTS_INSERT) already inserted.");
throw torrent::internal_error("View::received(..., SLOTS_INSERT) already inserted.");
if (view_downloads_filter(m_filter)(download))
insert_visible(download);
@@ -215,7 +215,7 @@ View::received(core::Download* download, int event) {
base_type::insert(end_filtered(), download);
if (m_focus > m_size)
throw torrent::client_error("View::received(...) m_focus > m_size.");
throw torrent::internal_error("View::received(...) m_focus > m_size.");
break;
@@ -225,7 +225,7 @@ View::received(core::Download* download, int event) {
default:
if (itr == end_filtered())
throw torrent::client_error("View::received(..., SLOTS_*) could not find download.");
throw torrent::internal_error("View::received(..., SLOTS_*) could not find download.");
if (view_downloads_filter(m_filter)(download)) {
+1 -1
View File
@@ -162,7 +162,7 @@ ViewManager::clear() {
ViewManager::iterator
ViewManager::insert(const std::string& name) {
if (find(name) != end())
throw torrent::client_error("ViewManager::insert(...) name already inserted.");
throw torrent::internal_error("ViewManager::insert(...) name already inserted.");
View* view = new View();
view->initialize(name, m_list);