Forces exceptions to throw on HAL handle creation functions (#209)

Fixes #199
This commit is contained in:
Thad House
2016-09-29 20:18:40 -07:00
committed by Peter Johnson
parent 81e63ea3a5
commit a656207220
11 changed files with 41 additions and 24 deletions

View File

@@ -14,19 +14,24 @@
extern JavaVM *jvm;
void ReportError(JNIEnv *env, int32_t status, int32_t minRange, int32_t maxRange,
int32_t requestedValue, bool do_throw = true);
void ReportError(JNIEnv *env, int32_t status, bool do_throw = true);
void ThrowError(JNIEnv *env, int32_t status, int32_t minRange, int32_t maxRange,
int32_t requestedValue);
inline bool CheckStatus(JNIEnv *env, int32_t status, bool do_throw = true) {
if (status != 0) ReportError(env, status, 0, 0, 0, do_throw);
if (status != 0) ReportError(env, status, do_throw);
return status == 0;
}
inline bool CheckStatusRange(JNIEnv *env, int32_t status, int32_t minRange,
int32_t maxRange, int32_t requestedValue,
bool do_throw = true) {
if (status != 0) ReportError(env, status, minRange, maxRange, requestedValue,
do_throw);
int32_t maxRange, int32_t requestedValue) {
if (status != 0) ThrowError(env, status, minRange, maxRange, requestedValue);
return status == 0;
}
inline bool CheckStatusForceThrow(JNIEnv *env, int32_t status) {
if (status != 0) ThrowError(env, status, 0, 0, 0);
return status == 0;
}