diff --git a/bindings/java/src/jni/win32/util.c b/bindings/java/src/jni/win32/util.c index b3feefca..2b17c9bb 100644 --- a/bindings/java/src/jni/win32/util.c +++ b/bindings/java/src/jni/win32/util.c @@ -21,13 +21,18 @@ void win32_throw_exception(JNIEnv *env, char *msg) } void win32_throw_last_error(JNIEnv *env) +{ + win32_throw_error(env, GetLastError()); +} + +void win32_throw_error(JNIEnv *env, LONG err) { char msg[8192]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, - GetLastError(), + err, 0, /* default language */ (LPTSTR)msg, (DWORD)sizeof(msg), diff --git a/bindings/java/src/jni/win32/win32bindings.h b/bindings/java/src/jni/win32/win32bindings.h index 1b16fad0..190336db 100644 --- a/bindings/java/src/jni/win32/win32bindings.h +++ b/bindings/java/src/jni/win32/win32bindings.h @@ -28,6 +28,8 @@ extern "C" { #endif void win32_throw_exception(JNIEnv *env, char *msg); + void win32_throw_error(JNIEnv *env, LONG err); + void win32_throw_last_error(JNIEnv *env); #ifdef __cplusplus }