Task #3953 - Inherit XArch and XBase from std::exception

This commit is contained in:
Nick Bolton 2014-03-14 18:30:21 +00:00
parent 78f30db6e9
commit abe108195d
9 changed files with 21 additions and 30 deletions

View File

@ -22,7 +22,7 @@
// XArch // XArch
// //
std::string const char*
XArch::what() const throw() XArch::what() const throw()
{ {
try { try {
@ -33,5 +33,5 @@ XArch::what() const throw()
catch (...) { catch (...) {
// ignore // ignore
} }
return m_what; return m_what.c_str();
} }

View File

@ -63,7 +63,7 @@ public:
}; };
//! Generic exception architecture dependent library //! Generic exception architecture dependent library
class XArch { class XArch : public std::exception {
public: public:
XArch(XArchEval* adoptedEvaluator) : m_eval(adoptedEvaluator) { } XArch(XArchEval* adoptedEvaluator) : m_eval(adoptedEvaluator) { }
XArch(const std::string& msg) : m_eval(NULL), m_what(msg) { } XArch(const std::string& msg) : m_eval(NULL), m_what(msg) { }
@ -71,7 +71,7 @@ public:
m_what(e.m_what) { } m_what(e.m_what) { }
~XArch() { delete m_eval; } ~XArch() { delete m_eval; }
std::string what() const throw(); const char* what() const throw();
private: private:
XArchEval* m_eval; XArchEval* m_eval;

View File

@ -24,7 +24,7 @@
/*! /*!
This is the base class of most exception types. This is the base class of most exception types.
*/ */
class XBase { class XBase : public std::exception {
public: public:
//! Use getWhat() as the result of what() //! Use getWhat() as the result of what()
XBase(); XBase();

View File

@ -139,7 +139,7 @@ CIpcLogOutputter::bufferThread(void*)
} }
} }
catch (XArch& e) { catch (XArch& e) {
LOG((CLOG_ERR "ipc log buffer thread error, %s", e.what().c_str())); LOG((CLOG_ERR "ipc log buffer thread error, %s", e.what()));
} }
LOG((CLOG_DEBUG "ipc log buffer thread finished")); LOG((CLOG_DEBUG "ipc log buffer thread finished"));

View File

@ -200,7 +200,7 @@ CSocketMultiplexer::serviceThread(void*)
} }
} }
catch (XArchNetwork& e) { catch (XArchNetwork& e) {
LOG((CLOG_WARN "error in socket multiplexer: %s", e.what().c_str())); LOG((CLOG_WARN "error in socket multiplexer: %s", e.what()));
status = 0; status = 0;
} }

View File

@ -117,7 +117,7 @@ CTCPSocket::close()
} }
catch (XArchNetwork& e) { catch (XArchNetwork& e) {
// ignore, there's not much we can do // ignore, there's not much we can do
LOG((CLOG_WARN "error closing socket: %s", e.what().c_str())); LOG((CLOG_WARN "error closing socket: %s", e.what()));
} }
} }
} }
@ -433,7 +433,7 @@ CTCPSocket::serviceConnecting(ISocketMultiplexerJob* job,
ARCH->throwErrorOnSocket(m_socket); ARCH->throwErrorOnSocket(m_socket);
} }
catch (XArchNetwork& e) { catch (XArchNetwork& e) {
sendConnectionFailedEvent(e.what().c_str()); sendConnectionFailedEvent(e.what());
onDisconnected(); onDisconnected();
return newJob(); return newJob();
} }
@ -499,7 +499,7 @@ CTCPSocket::serviceConnected(ISocketMultiplexerJob* job,
} }
catch (XArchNetwork& e) { catch (XArchNetwork& e) {
// other write error // other write error
LOG((CLOG_WARN "error writing socket: %s", e.what().c_str())); LOG((CLOG_WARN "error writing socket: %s", e.what()));
onDisconnected(); onDisconnected();
sendEvent(m_events->forIStream().outputError()); sendEvent(m_events->forIStream().outputError());
sendEvent(m_events->forISocket().disconnected()); sendEvent(m_events->forISocket().disconnected());
@ -546,7 +546,7 @@ CTCPSocket::serviceConnected(ISocketMultiplexerJob* job,
} }
catch (XArchNetwork& e) { catch (XArchNetwork& e) {
// ignore other read error // ignore other read error
LOG((CLOG_WARN "error reading socket: %s", e.what().c_str())); LOG((CLOG_WARN "error reading socket: %s", e.what()));
} }
} }

View File

@ -215,14 +215,14 @@ CMSWindowsWatchdog::mainLoop(void*)
ARCH->sleep(1); ARCH->sleep(1);
} }
catch (XArch& e) { catch (std::exception& e) {
LOG((CLOG_ERR "failed to launch, error: %s", e.what().c_str())); LOG((CLOG_ERR "failed to launch, error: %s", e.what()));
m_processFailures++; m_processFailures++;
m_processRunning = false; m_processRunning = false;
continue; continue;
} }
catch (XSynergy& e) { catch (...) {
LOG((CLOG_ERR "failed to launch, error: %s", e.what())); LOG((CLOG_ERR "failed to launch, unknown error."));
m_processFailures++; m_processFailures++;
m_processRunning = false; m_processRunning = false;
continue; continue;

View File

@ -313,17 +313,11 @@ CApp::run(int argc, char** argv)
// using the exit(int) function! // using the exit(int) function!
result = e.getCode(); result = e.getCode();
} }
catch (XBase& e) {
LOG((CLOG_CRIT "Exception: %s\n", e.what()));
}
catch (XArch& e) {
LOG((CLOG_CRIT "Init failed: %s" BYE, e.what().c_str(), argsBase().m_pname));
}
catch (std::exception& e) { catch (std::exception& e) {
LOG((CLOG_CRIT "Exception: %s\n", e.what())); LOG((CLOG_CRIT "An error occurred: %s\n", e.what()));
} }
catch (...) { catch (...) {
LOG((CLOG_CRIT "An unexpected exception occurred.\n")); LOG((CLOG_CRIT "An unknown error occurred.\n"));
} }
appUtil().beforeAppExit(); appUtil().beforeAppExit();

View File

@ -248,14 +248,11 @@ CDaemonApp::mainLoop(bool logToFile)
DAEMON_RUNNING(false); DAEMON_RUNNING(false);
} }
catch (XArch& e) {
LOG((CLOG_ERR "xarch exception: %s", e.what().c_str()));
}
catch (std::exception& e) { catch (std::exception& e) {
LOG((CLOG_ERR "std exception: %s", e.what())); LOG((CLOG_CRIT "An error occurred: %s", e.what()));
} }
catch (...) { catch (...) {
LOG((CLOG_ERR "unrecognized error.")); LOG((CLOG_CRIT "An unknown error occurred.\n"));
} }
} }
@ -318,7 +315,7 @@ CDaemonApp::handleIpcMessage(const CEvent& e, void*)
CLOG->setFilter(logLevel.c_str()); CLOG->setFilter(logLevel.c_str());
} }
catch (XArch& e) { catch (XArch& e) {
LOG((CLOG_ERR "failed to save LogLevel setting, %s", e.what().c_str())); LOG((CLOG_ERR "failed to save LogLevel setting, %s", e.what()));
} }
} }
} }
@ -335,7 +332,7 @@ CDaemonApp::handleIpcMessage(const CEvent& e, void*)
ARCH->setting("Elevate", CString(cm->elevate() ? "1" : "0")); ARCH->setting("Elevate", CString(cm->elevate() ? "1" : "0"));
} }
catch (XArch& e) { catch (XArch& e) {
LOG((CLOG_ERR "failed to save settings, %s", e.what().c_str())); LOG((CLOG_ERR "failed to save settings, %s", e.what()));
} }
#if SYSAPI_WIN32 #if SYSAPI_WIN32