diff options
author | John Wiegley <johnw@newartisans.com> | 2004-07-29 01:56:53 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-07-29 01:56:53 -0400 |
commit | a2f805ef73010de7f136eba5682a909cdae3e09b (patch) | |
tree | 8db89762249e833a3c43d48a70bf7d8a3f802c87 /textual.cc | |
parent | c598550d50b23f80b3481e831d5a3261b0800e79 (diff) | |
download | fork-ledger-a2f805ef73010de7f136eba5682a909cdae3e09b.tar.gz fork-ledger-a2f805ef73010de7f136eba5682a909cdae3e09b.tar.bz2 fork-ledger-a2f805ef73010de7f136eba5682a909cdae3e09b.zip |
Exit if parsing errors are encountered
Diffstat (limited to 'textual.cc')
-rw-r--r-- | textual.cc | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -504,20 +504,18 @@ entry_t * parse_entry(std::istream& in, ledger_t * ledger, // Textual ledger parser // -unsigned int parse_textual_ledger(std::istream& in, ledger_t *& ledger, +unsigned int parse_textual_ledger(std::istream& in, ledger_t * ledger, account_t * master) { static char line[MAX_LINE + 1]; char c; - int count = 0; + unsigned int count = 0; + unsigned int errors = 0; commodity_t * time_commodity = NULL; std::list<account_t *> account_stack; automated_transactions_t auto_xacts; - if (! ledger) - ledger = new ledger_t; - if (! master) master = ledger->master; @@ -761,7 +759,8 @@ unsigned int parse_textual_ledger(std::istream& in, ledger_t *& ledger, } } catch (const parse_error& err) { - std::cerr << err.what() << std::endl; + std::cerr << "Error: " << err.what() << std::endl; + errors++; } } @@ -772,6 +771,12 @@ unsigned int parse_textual_ledger(std::istream& in, ledger_t *& ledger, COMMODITY_STYLE_NOMARKET); } + if (errors > 0) { + std::ostringstream msg; + msg << "Errors parsing file '" << path << "'"; + throw error(msg.str()); + } + return count; } |