Error Handling
- Errors that occur during initialization no longer prevent the display of debug info.
This commit is contained in:
@@ -65,10 +65,13 @@ Context::~Context ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Context::initialize (int argc, const char** argv)
|
int Context::initialize (int argc, const char** argv)
|
||||||
{
|
{
|
||||||
Timer t ("Context::initialize");
|
Timer t ("Context::initialize");
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// char** argv --> std::vector <std::string> Context::args.
|
// char** argv --> std::vector <std::string> Context::args.
|
||||||
// TODO Handle "cal" case here.
|
// TODO Handle "cal" case here.
|
||||||
args.capture (argc, argv);
|
args.capture (argc, argv);
|
||||||
@@ -146,6 +149,32 @@ void Context::initialize (int argc, const char** argv)
|
|||||||
hooks.trigger ("on-launch");
|
hooks.trigger ("on-launch");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch (const std::string& error)
|
||||||
|
{
|
||||||
|
footnote (error);
|
||||||
|
rc = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
footnote (STRING_UNKNOWN_ERROR);
|
||||||
|
rc = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dump all debug messages, controlled by rc.debug.
|
||||||
|
if (rc && config.getBoolean ("debug"))
|
||||||
|
{
|
||||||
|
std::vector <std::string>::iterator d;
|
||||||
|
for (d = debugMessages.begin (); d != debugMessages.end (); ++d)
|
||||||
|
if (color ())
|
||||||
|
std::cout << colorizeDebug (*d) << "\n";
|
||||||
|
else
|
||||||
|
std::cout << *d << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Context::run ()
|
int Context::run ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
Context (const Context&);
|
Context (const Context&);
|
||||||
Context& operator= (const Context&);
|
Context& operator= (const Context&);
|
||||||
|
|
||||||
void initialize (int, const char**); // all startup
|
int initialize (int, const char**); // all startup
|
||||||
int run ();
|
int run ();
|
||||||
int dispatch (std::string&); // command handler dispatch
|
int dispatch (std::string&); // command handler dispatch
|
||||||
void shadow (); // shadow file update
|
void shadow (); // shadow file update
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ int main (int argc, const char** argv)
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
context.initialize (argc, argv);
|
status = context.initialize (argc, argv);
|
||||||
|
if (status == 0)
|
||||||
status = context.run ();
|
status = context.run ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user