]> mj.ucw.cz Git - paperjam.git/blobdiff - parse.cc
Better error messages from instantiating and running of commands
[paperjam.git] / parse.cc
index 5158eeb72fa3031295f7b752d34d319d15b2da31..8e7de38b3aec6a52f57a3f72bb23a98158f3aee4 100644 (file)
--- a/parse.cc
+++ b/parse.cc
@@ -78,7 +78,8 @@ static token_type get_next_token()
       while (*in_pos >= 'A' && *in_pos <= 'Z' ||
             *in_pos >= 'a' && *in_pos <= 'z' ||
             *in_pos >= '0' && *in_pos <= '9' ||
-            *in_pos == '_')
+            *in_pos == '_' ||
+            *in_pos == '-')
        token += *in_pos++;
       return TOK_IDENT;
     }
@@ -474,7 +475,14 @@ static void instantiate(list<cmd *> &cmds)
 {
   for (auto c: cmds)
     {
-      c->exec = c->def->constructor(c);
+      try
+       {
+         c->exec = c->def->constructor(c);
+       }
+      catch (exception &e)
+       {
+         die("Error in %s: %s", c->def->name, e.what());
+       }
       if (c->pipe)
        {
          for (auto pb: c->pipe->branches)