From 3934ed5f92eeb9046c3e4a7f7ce42d56bb704752 Mon Sep 17 00:00:00 2001
From: Thomas Moulard <thomas.moulard@gmail.com>
Date: Fri, 31 Dec 2010 19:14:38 +0100
Subject: [PATCH] Improve error management in import.

---
 src/dgraph/import.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/dgraph/import.cpp b/src/dgraph/import.cpp
index 9f93fb7..9f2bf4f 100644
--- a/src/dgraph/import.cpp
+++ b/src/dgraph/import.cpp
@@ -314,6 +314,15 @@ namespace dynamicgraph
       std::string path;
       cmdArg >> path;
       removeQuotes (path);
+      if (path.empty ())
+	DG_THROW ExceptionFactory
+	  (ExceptionFactory::SYNTAX_ERROR,
+	   "pushImportPaths expects exactly one argument.");
+
+      if (!cmdArg.eof ())
+	DG_THROW ExceptionFactory
+	  (ExceptionFactory::SYNTAX_ERROR,
+	   "pushImportPaths expects exactly one argument.");
 
       importPaths.push_back (path);
     }
@@ -331,6 +340,11 @@ namespace dynamicgraph
 	}
       if (!importPaths.empty ())
 	importPaths.pop_back ();
+      else
+	//FIXME: get a better error code for this.
+	DG_THROW ExceptionFactory
+	  (ExceptionFactory::SYNTAX_ERROR,
+	   "Vector is already empty.");
     }
 
   } // end of namespace command.
-- 
GitLab