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

View File

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

View File

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

View File

@ -139,7 +139,7 @@ CIpcLogOutputter::bufferThread(void*)
}
}
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"));

View File

@ -200,7 +200,7 @@ CSocketMultiplexer::serviceThread(void*)
}
}
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;
}

View File

@ -117,7 +117,7 @@ CTCPSocket::close()
}
catch (XArchNetwork& e) {
// 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);
}
catch (XArchNetwork& e) {
sendConnectionFailedEvent(e.what().c_str());
sendConnectionFailedEvent(e.what());
onDisconnected();
return newJob();
}
@ -499,7 +499,7 @@ CTCPSocket::serviceConnected(ISocketMultiplexerJob* job,
}
catch (XArchNetwork& e) {
// other write error
LOG((CLOG_WARN "error writing socket: %s", e.what().c_str()));
LOG((CLOG_WARN "error writing socket: %s", e.what()));
onDisconnected();
sendEvent(m_events->forIStream().outputError());
sendEvent(m_events->forISocket().disconnected());
@ -546,7 +546,7 @@ CTCPSocket::serviceConnected(ISocketMultiplexerJob* job,
}
catch (XArchNetwork& e) {
// 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);
}
catch (XArch& e) {
LOG((CLOG_ERR "failed to launch, error: %s", e.what().c_str()));
catch (std::exception& e) {
LOG((CLOG_ERR "failed to launch, error: %s", e.what()));
m_processFailures++;
m_processRunning = false;
continue;
}
catch (XSynergy& e) {
LOG((CLOG_ERR "failed to launch, error: %s", e.what()));
catch (...) {
LOG((CLOG_ERR "failed to launch, unknown error."));
m_processFailures++;
m_processRunning = false;
continue;

View File

@ -313,17 +313,11 @@ CApp::run(int argc, char** argv)
// using the exit(int) function!
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) {
LOG((CLOG_CRIT "Exception: %s\n", e.what()));
LOG((CLOG_CRIT "An error occurred: %s\n", e.what()));
}
catch (...) {
LOG((CLOG_CRIT "An unexpected exception occurred.\n"));
LOG((CLOG_CRIT "An unknown error occurred.\n"));
}
appUtil().beforeAppExit();

View File

@ -248,14 +248,11 @@ CDaemonApp::mainLoop(bool logToFile)
DAEMON_RUNNING(false);
}
catch (XArch& e) {
LOG((CLOG_ERR "xarch exception: %s", e.what().c_str()));
}
catch (std::exception& e) {
LOG((CLOG_ERR "std exception: %s", e.what()));
LOG((CLOG_CRIT "An error occurred: %s", e.what()));
}
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());
}
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"));
}
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