diff options
author | John Wiegley <johnw@newartisans.com> | 2009-10-31 04:07:06 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-10-31 04:07:41 -0400 |
commit | a51b7ec4faf7eae30588aad29e8979e3cd8b4678 (patch) | |
tree | 60de177300541a5fa311e83e064c804d3c24c571 /src/main.cc | |
parent | d7a06a31aaff7f662718c96eaa4106e3a06f7b40 (diff) | |
download | fork-ledger-a51b7ec4faf7eae30588aad29e8979e3cd8b4678.tar.gz fork-ledger-a51b7ec4faf7eae30588aad29e8979e3cd8b4678.tar.bz2 fork-ledger-a51b7ec4faf7eae30588aad29e8979e3cd8b4678.zip |
Construct global_scope object within the exception handler
Diffstat (limited to 'src/main.cc')
-rw-r--r-- | src/main.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.cc b/src/main.cc index 9f0e8690..0aec8886 100644 --- a/src/main.cc +++ b/src/main.cc @@ -76,11 +76,13 @@ int main(int argc, char * argv[], char * envp[]) ::textdomain("ledger"); #endif - // Create the session object, which maintains nearly all state relating to - // this invocation of Ledger; and register all known journal parsers. - std::auto_ptr<global_scope_t> global_scope(new global_scope_t(envp)); + std::auto_ptr<global_scope_t> global_scope; try { + // Create the session object, which maintains nearly all state relating to + // this invocation of Ledger; and register all known journal parsers. + global_scope.reset(new global_scope_t(envp)); + global_scope->session().set_flush_on_next_data_file(true); // Construct an STL-style argument list from the process command arguments @@ -181,7 +183,11 @@ int main(int argc, char * argv[], char * envp[]) } } catch (const std::exception& err) { - global_scope->report_error(err); + if (global_scope.get()) + global_scope->report_error(err); + else + std::cerr << "Exception during initialization: " << err.what() + << std::endl; } catch (int _status) { status = _status; // used for a "quick" exit, and is used only |