diff options
| author | a1xd <[email protected]> | 2020-08-11 23:15:02 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2020-08-11 23:15:02 -0400 |
| commit | c7f881c86913f309f00f79289b2f3c88ce6919eb (patch) | |
| tree | 7ffc41237725e3ec0e9f53313644365912ded060 /common/rawaccel-io.hpp | |
| parent | add a cooldown on write (one second) (diff) | |
| download | rawaccel-c7f881c86913f309f00f79289b2f3c88ce6919eb.tar.xz rawaccel-c7f881c86913f309f00f79289b2f3c88ce6919eb.zip | |
define exceptions for invalid arg & io errors
Diffstat (limited to 'common/rawaccel-io.hpp')
| -rw-r--r-- | common/rawaccel-io.hpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/common/rawaccel-io.hpp b/common/rawaccel-io.hpp index fc64c7d..7f55392 100644 --- a/common/rawaccel-io.hpp +++ b/common/rawaccel-io.hpp @@ -21,7 +21,7 @@ namespace rawaccel { ra_handle = CreateFileW(L"\\\\.\\rawaccel", 0, 0, 0, OPEN_EXISTING, 0, 0); if (ra_handle == INVALID_HANDLE_VALUE) { - throw std::system_error(GetLastError(), std::system_category(), "CreateFile failed"); + throw install_error(); } mouse_modifier mod; @@ -54,7 +54,7 @@ namespace rawaccel { ra_handle = CreateFileW(L"\\\\.\\rawaccel", 0, 0, 0, OPEN_EXISTING, 0, 0); if (ra_handle == INVALID_HANDLE_VALUE) { - throw std::system_error(GetLastError(), std::system_category(), "CreateFile failed"); + throw install_error(); } DWORD dummy; @@ -73,7 +73,10 @@ namespace rawaccel { CloseHandle(ra_handle); if (!success) { - throw std::system_error(GetLastError(), std::system_category(), "DeviceIoControl failed"); + if (auto err = GetLastError(); err != ERROR_BUSY) { + throw std::system_error(err, std::system_category(), "DeviceIoControl failed"); + } + throw cooldown_error(); } } |