Skip to content
This repository was archived by the owner on Jul 26, 2026. It is now read-only.

Commit 5b99169

Browse files
committed
arch: Remove XArch exception class
XArch no longer contains any extra functionality in addition to what std::runtime_error nor it signifies a particular type of error.
1 parent 22aec16 commit 5b99169

9 files changed

Lines changed: 26 additions & 31 deletions

File tree

src/lib/arch/XArch.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,12 @@ cleanup but before leaving or returning from the handler.
4646
#define RETHROW_XTHREAD \
4747
try { throw; } catch (XThread&) { throw; } catch (...) { }
4848

49-
//! Generic exception architecture dependent library
50-
class XArch : public std::runtime_error {
51-
public:
52-
XArch(const std::string& msg) : std::runtime_error(msg) { }
53-
virtual ~XArch() noexcept { }
54-
};
55-
5649
//! Generic network exception
5750
/*!
5851
Exceptions derived from this class are used by the networking
5952
library to indicate various errors.
6053
*/
61-
class XArchNetwork : public XArch { using XArch::XArch; };
54+
class XArchNetwork : public std::runtime_error { using std::runtime_error::runtime_error; };
6255

6356
//! Operation was interrupted
6457
class XArchNetworkInterrupted : public XArchNetwork { using XArchNetwork::XArchNetwork; };
@@ -132,7 +125,7 @@ class XArchNetworkNameUnsupported : public XArchNetworkName {
132125
Exceptions derived from this class are used by the daemon
133126
library to indicate various errors.
134127
*/
135-
class XArchDaemon : public XArch { using XArch::XArch; };
128+
class XArchDaemon : public std::runtime_error { using std::runtime_error::runtime_error; };
136129

137130
//! Could not daemonize
138131
class XArchDaemonFailed : public XArchDaemon { using XArchDaemon::XArchDaemon; };

src/lib/arch/win32/ArchSystemWindows.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <windows.h>
2727
#include <psapi.h>
2828

29+
#include <stdexcept>
30+
2931
static const char* s_settingsKeyNames[] = {
3032
_T("SOFTWARE"),
3133
_T("Barrier"),
@@ -103,7 +105,7 @@ ArchSystemWindows::setting(const std::string& valueName, const std::string& valu
103105
{
104106
HKEY key = ArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_settingsKeyNames);
105107
if (key == nullptr)
106-
throw XArch(std::string("could not access registry key: ") + valueName);
108+
throw std::runtime_error(std::string("could not access registry key: ") + valueName);
107109
ArchMiscWindows::setValue(key, valueName.c_str(), valueString.c_str());
108110
}
109111

src/lib/inputleap/win32/AppUtilWindows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ AppUtilWindows::AppUtilWindows(IEventQueue* events) :
4444
{
4545
if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandler, TRUE) == FALSE)
4646
{
47-
throw XArch(error_code_to_string_windows(GetLastError()));
47+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
4848
}
4949
}
5050

src/lib/inputleap/win32/DaemonApp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ DaemonApp::run(int argc, char** argv)
143143

144144
return kExitSuccess;
145145
}
146-
catch (XArch& e) {
146+
catch (std::runtime_error& e) {
147147
std::string message = e.what();
148148
if (uninstall && (message.find("The service has not been started") != std::string::npos)) {
149149
// TODO: if we're keeping this use error code instead (what is it?!).
@@ -295,7 +295,7 @@ DaemonApp::handleIpcMessage(const Event& e, void*)
295295
ARCH->setting("LogLevel", logLevel);
296296
CLOG->setFilter(logLevel.c_str());
297297
}
298-
catch (XArch& e) {
298+
catch (std::runtime_error& e) {
299299
LOG((CLOG_ERR "failed to save LogLevel setting, %s", e.what()));
300300
}
301301
}
@@ -328,7 +328,7 @@ DaemonApp::handleIpcMessage(const Event& e, void*)
328328
// TODO: it would be nice to store bools/ints...
329329
ARCH->setting("Elevate", std::string(cm->elevate() ? "1" : "0"));
330330
}
331-
catch (XArch& e) {
331+
catch (std::runtime_error& e) {
332332
LOG((CLOG_ERR "failed to save settings, %s", e.what()));
333333
}
334334

src/lib/ipc/IpcLogOutputter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void IpcLogOutputter::buffer_thread()
153153
sendBuffer();
154154
}
155155
}
156-
catch (XArch& e) {
156+
catch (std::runtime_error& e) {
157157
LOG((CLOG_ERR "ipc log buffer thread error, %s", e.what()));
158158
}
159159

src/lib/platform/MSWindowsSession.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ MSWindowsSession::isProcessInSession(const char* name, PHANDLE process = nullptr
3939
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
4040
if (snapshot == INVALID_HANDLE_VALUE) {
4141
LOG((CLOG_ERR "could not get process snapshot"));
42-
throw XArch(error_code_to_string_windows(GetLastError()));
42+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
4343
}
4444

4545
PROCESSENTRY32 entry;
@@ -50,7 +50,7 @@ MSWindowsSession::isProcessInSession(const char* name, PHANDLE process = nullptr
5050
BOOL gotEntry = Process32First(snapshot, &entry);
5151
if (!gotEntry) {
5252
LOG((CLOG_ERR "could not get first process entry"));
53-
throw XArch(error_code_to_string_windows(GetLastError()));
53+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
5454
}
5555

5656
// used to record process names for debug info
@@ -125,7 +125,7 @@ MSWindowsSession::getUserToken(LPSECURITY_ATTRIBUTES security)
125125
HANDLE sourceToken;
126126
if (!WTSQueryUserToken(m_activeSessionId, &sourceToken)) {
127127
LOG((CLOG_ERR "could not get token from session %d", m_activeSessionId));
128-
throw XArch(error_code_to_string_windows(GetLastError());
128+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
129129
}
130130

131131
HANDLE newToken;
@@ -134,7 +134,7 @@ MSWindowsSession::getUserToken(LPSECURITY_ATTRIBUTES security)
134134
SecurityImpersonation, TokenPrimary, &newToken)) {
135135

136136
LOG((CLOG_ERR "could not duplicate token"));
137-
throw XArch(error_code_to_string_windows(GetLastError());
137+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
138138
}
139139

140140
LOG((CLOG_DEBUG "duplicated, new token: %i", newToken));
@@ -165,7 +165,7 @@ MSWindowsSession::nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry)
165165

166166
// only worry about error if it's not the end of the snapshot
167167
LOG((CLOG_ERR "could not get next process entry"));
168-
throw XArch(error_code_to_string_windows(GetLastError()));
168+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
169169
}
170170
}
171171

src/lib/platform/MSWindowsWatchdog.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ MSWindowsWatchdog::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES s
112112

113113
if (!tokenRet) {
114114
LOG((CLOG_ERR "could not open token, process handle: %d", process));
115-
throw XArch(error_code_to_string_windows(GetLastError()));
115+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
116116
}
117117

118118
LOG((CLOG_DEBUG "got token %i, duplicating", sourceToken));
@@ -124,7 +124,7 @@ MSWindowsWatchdog::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES s
124124

125125
if (!duplicateRet) {
126126
LOG((CLOG_ERR "could not duplicate token %i", sourceToken));
127-
throw XArch(error_code_to_string_windows(GetLastError()));
127+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
128128
}
129129

130130
LOG((CLOG_DEBUG "duplicated, new token: %i", newToken));
@@ -171,7 +171,7 @@ void MSWindowsWatchdog::main_loop()
171171
saAttr.lpSecurityDescriptor = nullptr;
172172

173173
if (!CreatePipe(&m_stdOutRead, &m_stdOutWrite, &saAttr, 0)) {
174-
throw XArch(error_code_to_string_windows(GetLastError()));
174+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
175175
}
176176

177177
ZeroMemory(&m_processInfo, sizeof(PROCESS_INFORMATION));
@@ -304,7 +304,7 @@ MSWindowsWatchdog::startProcess()
304304
DWORD exitCode = 0;
305305
GetExitCodeProcess(m_processInfo.hProcess, &exitCode);
306306
LOG((CLOG_ERR "exit code: %d", exitCode));
307-
throw XArch(error_code_to_string_windows(GetLastError());
307+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
308308
}
309309
else {
310310
// wait for program to fail.
@@ -360,7 +360,7 @@ BOOL MSWindowsWatchdog::doStartProcessAsUser(std::string& command, HANDLE userTo
360360
BOOL blockRet = CreateEnvironmentBlock(&environment, userToken, FALSE);
361361
if (!blockRet) {
362362
LOG((CLOG_ERR "could not create environment block"));
363-
throw XArch(error_code_to_string_windows(GetLastError());
363+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
364364
}
365365

366366
DWORD creationFlags =
@@ -488,7 +488,7 @@ MSWindowsWatchdog::shutdownExistingProcesses()
488488
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
489489
if (snapshot == INVALID_HANDLE_VALUE) {
490490
LOG((CLOG_ERR "could not get process snapshot"));
491-
throw XArch(error_code_to_string_windows(GetLastError());
491+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
492492
}
493493

494494
PROCESSENTRY32 entry;
@@ -499,7 +499,7 @@ MSWindowsWatchdog::shutdownExistingProcesses()
499499
BOOL gotEntry = Process32First(snapshot, &entry);
500500
if (!gotEntry) {
501501
LOG((CLOG_ERR "could not get first process entry"));
502-
throw XArch(error_code_to_string_windows(GetLastError());
502+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
503503
}
504504

505505
// now just iterate until we can find winlogon.exe pid
@@ -526,7 +526,7 @@ MSWindowsWatchdog::shutdownExistingProcesses()
526526

527527
// only worry about error if it's not the end of the snapshot
528528
LOG((CLOG_ERR "could not get subsiquent process entry"));
529-
throw XArch(error_code_to_string_windows(GetLastError());
529+
throw std::runtime_error(error_code_to_string_windows(GetLastError()));
530530
}
531531
}
532532
}

src/lib/platform/OSXScreen.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@
112112
#if defined(MAC_OS_X_VERSION_10_9)
113113
// we can't pass options to show the dialog, this must be done by the gui.
114114
if (!AXIsProcessTrusted()) {
115-
throw XArch("assistive devices does not trust this process, allow it in system settings.");
115+
throw std::runtime_error("assistive devices does not trust this process, allow it in system settings.");
116116
}
117117
#else
118118
// now deprecated in mavericks.
119119
if (!AXAPIEnabled()) {
120-
throw XArch("assistive devices is not enabled, enable it in system settings.");
120+
throw std::runtime_error("assistive devices is not enabled, enable it in system settings.");
121121
}
122122
#endif
123123
}

src/lib/platform/XWindowsScreen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ XWindowsScreen::XWindowsScreen(
100100

101101
// initializes Xlib support for concurrent threads.
102102
if (m_impl->XInitThreads() == 0)
103-
throw XArch("XInitThreads() returned zero");
103+
throw std::runtime_error("XInitThreads() returned zero");
104104

105105
// set the X I/O error handler so we catch the display disconnecting
106106
m_impl->XSetIOErrorHandler(&XWindowsScreen::ioErrorHandler);

0 commit comments

Comments
 (0)