]> git.tdb.fi Git - libs/datafile.git/commitdiff
Convenience function for reporting errors in loaded data
authorMikko Rasa <tdb@tdb.fi>
Wed, 18 Jul 2012 10:09:37 +0000 (13:09 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 18 Jul 2012 10:09:37 +0000 (13:09 +0300)
source/loader.cpp
source/loader.h

index 2bf90ee1e5ec9436e9306a09a7917c8e25e32cdc..ad62445f0be3e00a785695121e510f76cc7d4a5f 100644 (file)
@@ -176,6 +176,13 @@ const string &Loader::get_source() const
        return cur_st->source;
 }
 
+void Loader::error(const string &msg) const
+{
+       if(!cur_st)
+               throw logic_error("!cur_st");
+       throw data_error(cur_st->source, cur_st->line, msg);
+}
+
 
 Loader::ActionKey::ActionKey(const string &k, const string &s):
        keyword(k),
index 604886125614728c2552d486decfa01afa19c804..4a1faa3f7af650ff4f4ec3726cc768fea77255cb 100644 (file)
@@ -139,6 +139,9 @@ protected:
        source may not necessarily be a file. */
        const std::string &get_source() const;
 
+       /** Throws a data_error from the current line. */
+       void error(const std::string &) const;
+
        virtual void finish() { }
 };