mirror of
https://github.com/kiwix/java-libkiwix.git
synced 2025-09-10 07:36:26 -04:00
Do not catch (and hide) exception inner exception.
This commit is contained in:
parent
6c0e60c9c8
commit
1d49be8b99
@ -88,13 +88,8 @@ JNIEXPORT void JNICALL Java_org_kiwix_libzim_Archive_setNativeArchiveByFD(
|
|||||||
int fd = jni2fd(fdObj, env);
|
int fd = jni2fd(fdObj, env);
|
||||||
|
|
||||||
LOG("Attempting to create reader with fd: %d", fd);
|
LOG("Attempting to create reader with fd: %d", fd);
|
||||||
try {
|
auto archive = std::make_shared<zim::Archive>(fd);
|
||||||
auto archive = std::make_shared<zim::Archive>(fd);
|
SET_PTR(archive);
|
||||||
SET_PTR(archive);
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
LOG("Error opening ZIM file");
|
|
||||||
LOG("%s", e.what());
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
jclass exception = env->FindClass("java/lang/UnsupportedOperationException");
|
jclass exception = env->FindClass("java/lang/UnsupportedOperationException");
|
||||||
env->ThrowNew(exception, "org.kiwix.libzim.Archive.setNativeArchiveByFD() is not supported under Windows");
|
env->ThrowNew(exception, "org.kiwix.libzim.Archive.setNativeArchiveByFD() is not supported under Windows");
|
||||||
@ -108,13 +103,8 @@ JNIEXPORT void JNICALL Java_org_kiwix_libzim_Archive_setNativeArchiveEmbedded(
|
|||||||
int fd = jni2fd(fdObj, env);
|
int fd = jni2fd(fdObj, env);
|
||||||
|
|
||||||
LOG("Attempting to create reader with fd: %d", fd);
|
LOG("Attempting to create reader with fd: %d", fd);
|
||||||
try {
|
auto archive = std::make_shared<zim::Archive>(fd, offset, size);
|
||||||
auto archive = std::make_shared<zim::Archive>(fd, offset, size);
|
SET_PTR(archive);
|
||||||
SET_PTR(archive);
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
LOG("Error opening ZIM file");
|
|
||||||
LOG("%s", e.what());
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
jclass exception = env->FindClass("java/lang/UnsupportedOperationException");
|
jclass exception = env->FindClass("java/lang/UnsupportedOperationException");
|
||||||
env->ThrowNew(exception, "org.kiwix.libzim.Archive.setNativeArchiveEmbedded() is not supported under Windows");
|
env->ThrowNew(exception, "org.kiwix.libzim.Archive.setNativeArchiveEmbedded() is not supported under Windows");
|
||||||
@ -127,14 +117,8 @@ JNIEXPORT void JNICALL Java_org_kiwix_libzim_Archive_setNativeArchiveEmbeddedFd(
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
auto fdInput = jni2fdInput(fdObj, env);
|
auto fdInput = jni2fdInput(fdObj, env);
|
||||||
|
|
||||||
LOG("Attempting to create reader with fd: %d", fdInput);
|
auto archive = std::make_shared<zim::Archive>(fdInput);
|
||||||
try {
|
SET_PTR(archive);
|
||||||
auto archive = std::make_shared<zim::Archive>(fdInput);
|
|
||||||
SET_PTR(archive);
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
LOG("Error opening ZIM file");
|
|
||||||
LOG("%s", e.what());
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
jclass exception = env->FindClass("java/lang/UnsupportedOperationException");
|
jclass exception = env->FindClass("java/lang/UnsupportedOperationException");
|
||||||
env->ThrowNew(exception, "org.kiwix.libzim.Archive.setNativeArchiveEmbedded() is not supported under Windows");
|
env->ThrowNew(exception, "org.kiwix.libzim.Archive.setNativeArchiveEmbedded() is not supported under Windows");
|
||||||
@ -157,13 +141,8 @@ JNIEXPORT void JNICALL Java_org_kiwix_libzim_Archive_setNativeArchiveEmbeddedFds
|
|||||||
v.push_back(fdInput);
|
v.push_back(fdInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
auto archive = std::make_shared<zim::Archive>(v);
|
||||||
auto archive = std::make_shared<zim::Archive>(v);
|
SET_PTR(archive);
|
||||||
SET_PTR(archive);
|
|
||||||
} catch (std::exception& e) {
|
|
||||||
LOG("Error opening ZIM file");
|
|
||||||
LOG("%s", e.what());
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
jclass exception = env->FindClass("java/lang/UnsupportedOperationException");
|
jclass exception = env->FindClass("java/lang/UnsupportedOperationException");
|
||||||
env->ThrowNew(exception, "org.kiwix.libzim.Archive.setNativeArchiveEmbedded() is not supported under Windows");
|
env->ThrowNew(exception, "org.kiwix.libzim.Archive.setNativeArchiveEmbedded() is not supported under Windows");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user