diff options
| author | a1xd <[email protected]> | 2020-12-05 21:28:08 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-05 21:28:08 -0500 |
| commit | c8503654da5bc40a129e58914549cd394349d059 (patch) | |
| tree | e4760c579597d0e292c7b03dff95d19bb8f3c750 /wrapper/wrapper_io.cpp | |
| parent | Merge pull request #45 from JacobPalecki/fix (diff) | |
| parent | update signed, add installers (diff) | |
| download | rawaccel-c8503654da5bc40a129e58914549cd394349d059.tar.xz rawaccel-c8503654da5bc40a129e58914549cd394349d059.zip | |
Merge pull request #46 from a1xd/1.3
Diffstat (limited to 'wrapper/wrapper_io.cpp')
| -rw-r--r-- | wrapper/wrapper_io.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/wrapper/wrapper_io.cpp b/wrapper/wrapper_io.cpp index 0f257bf..4b77174 100644 --- a/wrapper/wrapper_io.cpp +++ b/wrapper/wrapper_io.cpp @@ -3,11 +3,10 @@ #include <rawaccel-io.hpp> #include "wrapper_io.hpp" -void wrapper_io::writeToDriver(const settings& args) -{ - try +auto with_managed_ex = [](auto fn) { + try { - write(args); + fn(); } catch (const install_error&) { @@ -17,20 +16,25 @@ void wrapper_io::writeToDriver(const settings& args) { throw gcnew DriverIOException(gcnew String(e.what())); } +}; + +void wrapper_io::writeToDriver(const settings& args) +{ + with_managed_ex([&] { + write(args); + }); } void wrapper_io::readFromDriver(settings& args) { - try - { + with_managed_ex([&] { args = read(); - } - catch (const install_error&) - { - throw gcnew DriverNotInstalledException(); - } - catch (const std::system_error& e) - { - throw gcnew DriverIOException(gcnew String(e.what())); - } + }); +} + +void wrapper_io::getDriverVersion(version_t& ver) +{ + with_managed_ex([&] { + ver = get_version(); + }); } |