From 99313ebc6c3779f692f9f1bd70cc69a236f5eb78 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 31 Jul 2008 06:24:45 -0400 Subject: 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. --- main.cc | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'main.cc') 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(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(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; -- cgit v1.2.3