jsWindows: throw exception instead of using an assert
Since asserts can be compiled as no-ops, throw an exception rather than doing assert(false), in case the code passed to joyGetDevCaps_errorString() is not one of the expected values.
This commit is contained in:
parent
babf0ded0c
commit
a5792617f7
1 changed files with 8 additions and 3 deletions
11
3rdparty/joystick/jsWindows.cxx
vendored
11
3rdparty/joystick/jsWindows.cxx
vendored
|
@ -27,10 +27,11 @@
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <RegStr.h> // for REGSTR_PATH_JOYCONFIG, etc
|
#include <RegStr.h> // for REGSTR_PATH_JOYCONFIG, etc
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
#include <simgear/structure/exception.hxx>
|
||||||
|
|
||||||
#define _JS_MAX_AXES_WIN 8 /* X,Y,Z,R,U,V,POV_X,POV_Y */
|
#define _JS_MAX_AXES_WIN 8 /* X,Y,Z,R,U,V,POV_X,POV_Y */
|
||||||
|
|
||||||
|
@ -53,10 +54,14 @@ static std::string joyGetDevCaps_errorString(MMRESULT errorCode)
|
||||||
case JOYERR_NOERROR:
|
case JOYERR_NOERROR:
|
||||||
return "no error";
|
return "no error";
|
||||||
default:
|
default:
|
||||||
assert(false);
|
throw sg_exception(
|
||||||
|
"Unexpected value passed to joyGetDevCaps_errorString(): "
|
||||||
|
+ std::to_string(errorCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return "bug: the program should not get here";
|
throw sg_exception("This code path should be unreachable; value "
|
||||||
|
"passed to joyGetDevCaps_errorString(): "
|
||||||
|
+ std::to_string(errorCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inspired by
|
// Inspired by
|
||||||
|
|
Loading…
Reference in a new issue