From 4b3951ab6a718c7a6699021e08a922935159491f Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Wed, 23 Jul 2014 15:37:00 +0200
Subject: [PATCH] GraphComponent throws out_of_range exception when ID is
 invalid.

---
 include/hpp/manipulation/graph/graph.hh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/hpp/manipulation/graph/graph.hh b/include/hpp/manipulation/graph/graph.hh
index 37e732a1..71d3c387 100644
--- a/include/hpp/manipulation/graph/graph.hh
+++ b/include/hpp/manipulation/graph/graph.hh
@@ -52,8 +52,12 @@ namespace hpp {
           /// Get the component by its ID. The validity of the GraphComponent
           /// is not checked.
           static GraphComponentWkPtr_t get(int id)
+            throw (std::out_of_range)
           {
-            HPP_ASSERT (id >= 0 && id < (int)components.size());
+# ifdef HPP_DEBUG
+            if (id < 0 || id >= (int)components.size())
+              throw std::out_of_range ("ID out of range.");
+# endif // HPP_DEBUG
             return components[id];
           };
 
-- 
GitLab