]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/loader.cpp
Report locations of errors through multiple levels of referenced files
[libs/datafile.git] / source / loader.cpp
index 51e22edf7a8e47c4ea1b02a3b1077d14e34f1f6e..3484799a3e4891b12b622139b646e27a582690a1 100644 (file)
@@ -54,12 +54,6 @@ Loader::Loader():
        check_sub_loads(false)
 { }
 
-Loader::~Loader()
-{
-       for(ActionMap::iterator i=local_actions.begin(); i!=local_actions.end(); ++i)
-               delete i->second;
-}
-
 void Loader::load(Parser &p)
 {
        if(!actions)
@@ -137,9 +131,12 @@ void Loader::load_statement(const Statement &st)
                                throw logic_error("substatements ignored");
                }
        }
-       catch(const data_error &)
+       catch(const data_error &e)
        {
-               throw;
+               if(e.get_source()!=st.source)
+                       throw data_error(st.source, st.line, e);
+               else
+                       throw;
        }
        catch(const exception &e)
        {
@@ -229,7 +226,7 @@ LoaderAction *Loader::find_action(const StatementKey &key) const
                }
        }
 
-       if(!act)
+       if(!match)
                throw invalid_signature(key.keyword, key.signature);
 
        return act;
@@ -249,5 +246,12 @@ const string &Loader::get_keyword() const
        return cur_st->keyword;
 }
 
+
+Loader::ActionMap::~ActionMap()
+{
+       for(iterator i=begin(); i!=end(); ++i)
+               delete i->second;
+}
+
 } // namespace DataFile
 } // namespace Msp