diff --git a/src/lib/arch/XArch.cpp b/src/lib/arch/XArch.cpp index f7446ce5..e377800e 100644 --- a/src/lib/arch/XArch.cpp +++ b/src/lib/arch/XArch.cpp @@ -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(); } diff --git a/src/lib/arch/XArch.h b/src/lib/arch/XArch.h index 887f079c..ed9e824a 100644 --- a/src/lib/arch/XArch.h +++ b/src/lib/arch/XArch.h @@ -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; diff --git a/src/lib/base/XBase.h b/src/lib/base/XBase.h index b6b5f23f..d265d609 100644 --- a/src/lib/base/XBase.h +++ b/src/lib/base/XBase.h @@ -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(); diff --git a/src/lib/ipc/IpcLogOutputter.cpp b/src/lib/ipc/IpcLogOutputter.cpp index f3924ae8..60c36510 100644 --- a/src/lib/ipc/IpcLogOutputter.cpp +++ b/src/lib/ipc/IpcLogOutputter.cpp @@ -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")); diff --git a/src/lib/net/SocketMultiplexer.cpp b/src/lib/net/SocketMultiplexer.cpp index 2463eeed..9a7874fe 100644 --- a/src/lib/net/SocketMultiplexer.cpp +++ b/src/lib/net/SocketMultiplexer.cpp @@ -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; } diff --git a/src/lib/net/TCPSocket.cpp b/src/lib/net/TCPSocket.cpp index c47854a5..3f90b57c 100644 --- a/src/lib/net/TCPSocket.cpp +++ b/src/lib/net/TCPSocket.cpp @@ -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())); } } diff --git a/src/lib/platform/MSWindowsWatchdog.cpp b/src/lib/platform/MSWindowsWatchdog.cpp index fac956aa..5ea22197 100644 --- a/src/lib/platform/MSWindowsWatchdog.cpp +++ b/src/lib/platform/MSWindowsWatchdog.cpp @@ -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; diff --git a/src/lib/synergy/App.cpp b/src/lib/synergy/App.cpp index 83065c07..e9e5e237 100644 --- a/src/lib/synergy/App.cpp +++ b/src/lib/synergy/App.cpp @@ -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(); diff --git a/src/lib/synergy/DaemonApp.cpp b/src/lib/synergy/DaemonApp.cpp index fd3bec92..e8e8007b 100644 --- a/src/lib/synergy/DaemonApp.cpp +++ b/src/lib/synergy/DaemonApp.cpp @@ -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