X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Fbinaryparser.cpp;h=550319f46d0a7af21bd939b477adaac1047101c8;hp=d2fca32ef3a2155eb78eec3034e67649336c3c0f;hb=d14b7ddd81404b909a4c4763a36a23b94998a089;hpb=67146b1b3bcb7d02307dcd4cc8b88cf778b41205 diff --git a/source/binaryparser.cpp b/source/binaryparser.cpp index d2fca32..550319f 100644 --- a/source/binaryparser.cpp +++ b/source/binaryparser.cpp @@ -9,6 +9,17 @@ using namespace std; namespace Msp { namespace DataFile { +class bad_definition: public runtime_error +{ +public: + bad_definition(const std::string &w): + runtime_error(w) + { } + + virtual ~bad_definition() throw() { } +}; + + BinaryParser::BinaryParser(Input &i, const string &s): ParserMode(i, s), first(true) @@ -25,7 +36,7 @@ Statement BinaryParser::parse() if(st.keyword=="__kwd") { if(st.args.size()!=3) - throw_at(TypeError("Keyword definition must have three arguments"), src); + throw bad_definition("__kwd"); const unsigned id = st.args[0].get(); const string &kw = st.args[1].get(); @@ -35,7 +46,7 @@ Statement BinaryParser::parse() else if(st.keyword=="__str") { if(st.args.size()!=2) - throw_at(TypeError("String definition must have two arguments"), src); + throw bad_definition("__str"); const unsigned id = st.args[0].get(); strings[id] = st.args[1].get();