]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/loader.cpp
Refactor exceptions
[libs/datafile.git] / source / loader.cpp
index e4993868ab3adfac95c385ef7c5d9e6a3c638a1c..8d4f2bea35b07f0cf485cbc50a8d22fe146b5cd1 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of libmspdatafile
-Copyright © 2006  Mikko Rasa, Mikkosoft Productions
+Copyright © 2006-2008  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -61,9 +61,20 @@ void Loader::load_statement(const Statement &st)
        cur_st=&st;
        ActionMap::iterator j=actions.find(st.keyword);
        if(j==actions.end())
-               throw KeyError(st.get_location()+": Unknown keyword", st.keyword);
+               throw_at(KeyError("Unknown keyword", st.keyword), st.get_location());
        if(j->second)
-               j->second->execute(*this, st);
+       {
+               try
+               {
+                       j->second->execute(*this, st);
+               }
+               catch(Exception &e)
+               {
+                       if(!e.where()[0])
+                               e.at(st.get_location());
+                       throw;
+               }
+       }
        cur_st=0;
 }