summaryrefslogtreecommitdiff
path: root/common/accel-base.hpp
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-08-11 23:15:02 -0400
committera1xd <[email protected]>2020-08-11 23:15:02 -0400
commitc7f881c86913f309f00f79289b2f3c88ce6919eb (patch)
tree7ffc41237725e3ec0e9f53313644365912ded060 /common/accel-base.hpp
parentadd a cooldown on write (one second) (diff)
downloadrawaccel-c7f881c86913f309f00f79289b2f3c88ce6919eb.tar.xz
rawaccel-c7f881c86913f309f00f79289b2f3c88ce6919eb.zip
define exceptions for invalid arg & io errors
Diffstat (limited to 'common/accel-base.hpp')
-rw-r--r--common/accel-base.hpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/common/accel-base.hpp b/common/accel-base.hpp
index da2c96b..91510a4 100644
--- a/common/accel-base.hpp
+++ b/common/accel-base.hpp
@@ -2,13 +2,20 @@
#include "vec2.h"
-namespace rawaccel {
+void bad_arg(const char*);
+
+#ifndef _KERNEL_MODE
- // Error throwing calls std libraries which are unavailable in kernel mode.
- void error(const char* s);
+#include "rawaccel-error.hpp"
- using milliseconds = double;
+inline void bad_arg(const char* s) {
+ throw rawaccel::invalid_argument(s);
+}
+#endif
+
+namespace rawaccel {
+
/// <summary> Struct to hold arguments for an acceleration function. </summary>
struct accel_args {
double offset = 0;
@@ -60,7 +67,7 @@ namespace rawaccel {
/// </summary>
/// <param name="args">Arguments to verified.</param>
void verify(const accel_args& args) const {
- if (args.accel < 0) error("accel can not be negative, use a negative weight to compensate");
+ if (args.accel < 0) bad_arg("accel can not be negative, use a negative weight to compensate");
}
accel_base() = default;