Permalink
Browse files

Use internal_error for priority queue exceptions.

  • Loading branch information...
rakshasa committed May 31, 2012
1 parent cf77a17 commit 78f64a3e084f1a3b23bee3970fcc89946d1f647c
Showing with 10 additions and 9 deletions.
  1. +10 −9 rak/priority_queue_default.h
@@ -37,12 +37,13 @@
#ifndef RAK_PRIORITY_QUEUE_DEFAULT_H
#define RAK_PRIORITY_QUEUE_DEFAULT_H
-#include <stdexcept>
#include <tr1/functional>
#include <rak/allocators.h>
#include <rak/priority_queue.h>
#include <rak/timer.h>
+#include "torrent/exceptions.h"
+
namespace rak {
class priority_item {
@@ -52,7 +53,7 @@ class priority_item {
priority_item() {}
~priority_item() {
if (is_queued())
- throw std::logic_error("priority_item::~priority_item() called on a queued item.");
+ throw torrent::internal_error("priority_item::~priority_item() called on a queued item.");
m_time = timer();
m_slot = slot_void();
@@ -101,16 +102,16 @@ priority_queue_perform(priority_queue_default* queue, timer t) {
inline void
priority_queue_insert(priority_queue_default* queue, priority_item* item, timer t) {
if (t == timer())
- throw std::logic_error("priority_queue_insert(...) received a bad timer.");
+ throw torrent::internal_error("priority_queue_insert(...) received a bad timer.");
if (!item->is_valid())
- throw std::logic_error("priority_queue_insert(...) called on an invalid item.");
+ throw torrent::internal_error("priority_queue_insert(...) called on an invalid item.");
if (item->is_queued())
- throw std::logic_error("priority_queue_insert(...) called on an already queued item.");
+ throw torrent::internal_error("priority_queue_insert(...) called on an already queued item.");
if (queue->find(item) != queue->end())
- throw std::logic_error("priority_queue_insert(...) item found in queue.");
+ throw torrent::internal_error("priority_queue_insert(...) item found in queue.");
item->set_time(t);
queue->push(item);
@@ -124,16 +125,16 @@ priority_queue_erase(priority_queue_default* queue, priority_item* item) {
// Check is_valid() after is_queued() so that it is safe to call
// erase on untouched instances.
if (!item->is_valid())
- throw std::logic_error("priority_queue_erase(...) called on an invalid item.");
+ throw torrent::internal_error("priority_queue_erase(...) called on an invalid item.");
// Clear time before erasing to force it to the top.
item->clear_time();
if (!queue->erase(item))
- throw std::logic_error("priority_queue_erase(...) could not find item in queue.");
+ throw torrent::internal_error("priority_queue_erase(...) could not find item in queue.");
if (queue->find(item) != queue->end())
- throw std::logic_error("priority_queue_erase(...) item still in queue.");
+ throw torrent::internal_error("priority_queue_erase(...) item still in queue.");
}
}

0 comments on commit 78f64a3

Please sign in to comment.