From c7f881c86913f309f00f79289b2f3c88ce6919eb Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Tue, 11 Aug 2020 23:15:02 -0400 Subject: define exceptions for invalid arg & io errors --- common/accel-base.hpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'common/accel-base.hpp') 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 { + /// Struct to hold arguments for an acceleration function. struct accel_args { double offset = 0; @@ -60,7 +67,7 @@ namespace rawaccel { /// /// Arguments to verified. 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; -- cgit v1.2.3