From b0b9af7216560da2a46ea38fe2df959f4dfb126f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 18 Jul 2012 13:09:37 +0300 Subject: [PATCH] Convenience function for reporting errors in loaded data --- source/loader.cpp | 7 +++++++ source/loader.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/source/loader.cpp b/source/loader.cpp index 2bf90ee..ad62445 100644 --- a/source/loader.cpp +++ b/source/loader.cpp @@ -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), diff --git a/source/loader.h b/source/loader.h index 6048861..4a1faa3 100644 --- a/source/loader.h +++ b/source/loader.h @@ -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() { } }; -- 2.43.0