@@ -1692,10 +1692,9 @@ namespace simplecpp {
16921692 }
16931693
16941694 /* * base class for errors */
1695- struct Error {
1696- Error (const Location &loc, const std::string &s) : location(loc ), what(s ) {}
1695+ struct Error : public std ::runtime_error {
1696+ Error (const Location &loc, const std::string &s) : std::runtime_error(s ), location(loc ) {}
16971697 const Location location;
1698- const std::string what;
16991698 };
17001699
17011700 /* * Struct that is thrown when macro is expanded with wrong number of parameters */
@@ -1739,6 +1738,9 @@ namespace simplecpp {
17391738 return tok;
17401739 }
17411740
1741+ /* *
1742+ * @throws Error thrown in case of __VA_OPT__ issues
1743+ */
17421744 bool parseDefine (const Token *nametoken) {
17431745 nameTokDef = nametoken;
17441746 variadic = false ;
@@ -3278,7 +3280,7 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
32783280 simplecpp::Output out{
32793281 simplecpp::Output::SYNTAX_ERROR,
32803282 err.location ,
3281- " failed to expand \' " + tok->str () + " \' , " + err.what
3283+ " failed to expand \' " + tok->str () + " \' , " + err.what ()
32823284 };
32833285 outputList->emplace_back (std::move (out));
32843286 }
@@ -3507,23 +3509,12 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35073509 else
35083510 it->second = macro;
35093511 }
3510- } catch (const std::runtime_error &) {
3512+ } catch (const std::runtime_error &err ) {
35113513 if (outputList) {
3512- simplecpp::Output err {
3514+ simplecpp::Output out {
35133515 Output::SYNTAX_ERROR,
35143516 rawtok->location ,
3515- " Failed to parse #define"
3516- };
3517- outputList->emplace_back (std::move (err));
3518- }
3519- output.clear ();
3520- return ;
3521- } catch (const simplecpp::Macro::Error &err) {
3522- if (outputList) {
3523- simplecpp::Output out{
3524- simplecpp::Output::SYNTAX_ERROR,
3525- err.location ,
3526- " Failed to parse #define, " + err.what
3517+ std::string (" Failed to parse #define, " ) + err.what ()
35273518 };
35283519 outputList->emplace_back (std::move (out));
35293520 }
0 commit comments