summaryrefslogtreecommitdiff
path: root/main.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-07-31 06:24:45 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-07-31 06:24:45 -0400
commit99313ebc6c3779f692f9f1bd70cc69a236f5eb78 (patch)
tree44a553891a9aaa148084d8e011b2d326401343e9 /main.cc
parent8afd926a27af55862ce360970e05d747f249a0da (diff)
downloadfork-ledger-99313ebc6c3779f692f9f1bd70cc69a236f5eb78.tar.gz
fork-ledger-99313ebc6c3779f692f9f1bd70cc69a236f5eb78.tar.bz2
fork-ledger-99313ebc6c3779f692f9f1bd70cc69a236f5eb78.zip
Revised the way that exceptions are thrown around. Instead of context being a
complicated string of pointers, it's now just a global block of text that gets appended to as the error is being thrown up, and can be displayed at the catch point if desired. There are almost no cases where a thrown exception will not result in an error message being displayed to the user.
Diffstat (limited to 'main.cc')
-rw-r--r--main.cc25
1 files changed, 3 insertions, 22 deletions
diff --git a/main.cc b/main.cc
index 4e475620..8d9f64dd 100644
--- a/main.cc
+++ b/main.cc
@@ -297,7 +297,7 @@ static int read_and_report(ledger::report_t& report, int argc, char * argv[],
command_args.push_back(value_t(out));
for (strings_list::iterator i = arg; i != args.end(); i++)
- command_args.push_back(value_t(*i, true));
+ command_args.push_back(string_value(*i));
INFO_START(command, "Did user command '" << verb << "'");
@@ -422,29 +422,10 @@ int main(int argc, char * argv[], char * envp[])
session.release();
}
}
- catch (ledger::error * err) {
- std::cout.flush();
- // Push a null here since there's no file context
- if (err->context.empty() ||
- ! dynamic_cast<ledger::xact_context *>(err->context.front()))
- err->context.push_front(new ledger::error_context(""));
- err->reveal_context(std::cerr, "Error");
- std::cerr << err->what() << std::endl;
- ledger::checked_delete(err);
- }
- catch (ledger::fatal * err) {
- std::cout.flush();
- // Push a null here since there's no file context
- if (err->context.empty() ||
- ! dynamic_cast<ledger::xact_context *>(err->context.front()))
- err->context.push_front(new ledger::error_context(""));
- err->reveal_context(std::cerr, "Fatal");
- std::cerr << err->what() << std::endl;
- ledger::checked_delete(err);
- }
catch (const std::exception& err) {
std::cout.flush();
- std::cerr << "Exception: " << err.what() << std::endl;
+ std::cerr << "Error: " << ledger::error_context() << err.what()
+ << std::endl;
}
catch (int _status) {
status = _status;