mirror of https://github.com/kiwix/libkiwix.git
Merge pull request #113 from kiwix/JNI_Reader_exception
Make JNIKiwixReader throw an exception if something goes wrong at creation.
This commit is contained in:
commit
698578ee73
|
@ -8,6 +8,7 @@ kiwix_jni = custom_target('jni',
|
||||||
'org/kiwix/kiwixlib/JNIKiwixInt.java',
|
'org/kiwix/kiwixlib/JNIKiwixInt.java',
|
||||||
'org/kiwix/kiwixlib/JNIKiwixString.java',
|
'org/kiwix/kiwixlib/JNIKiwixString.java',
|
||||||
'org/kiwix/kiwixlib/JNIKiwixBool.java',
|
'org/kiwix/kiwixlib/JNIKiwixBool.java',
|
||||||
|
'org/kiwix/kiwixlib/JNIKiwixException.java',
|
||||||
'org/kiwix/kiwixlib/Pair.java'],
|
'org/kiwix/kiwixlib/Pair.java'],
|
||||||
output: ['org_kiwix_kiwixlib_JNIKiwix.h',
|
output: ['org_kiwix_kiwixlib_JNIKiwix.h',
|
||||||
'org_kiwix_kiwixlib_JNIKiwixReader.h',
|
'org_kiwix_kiwixlib_JNIKiwixReader.h',
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Matthieu Gautier <mgautier@kymeria.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.kiwix.kiwixlib;
|
||||||
|
|
||||||
|
public class JNIKiwixException extends Exception
|
||||||
|
{
|
||||||
|
public JNIKiwixException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
package org.kiwix.kiwixlib;
|
package org.kiwix.kiwixlib;
|
||||||
|
|
||||||
|
import org.kiwix.kiwixlib.JNIKiwixException;
|
||||||
import org.kiwix.kiwixlib.JNIKiwixString;
|
import org.kiwix.kiwixlib.JNIKiwixString;
|
||||||
import org.kiwix.kiwixlib.JNIKiwixInt;
|
import org.kiwix.kiwixlib.JNIKiwixInt;
|
||||||
import org.kiwix.kiwixlib.JNIKiwixSearcher;
|
import org.kiwix.kiwixlib.JNIKiwixSearcher;
|
||||||
|
@ -109,9 +110,12 @@ public class JNIKiwixReader
|
||||||
return searcher;
|
return searcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JNIKiwixReader(String filename)
|
public JNIKiwixReader(String filename) throws JNIKiwixException
|
||||||
{
|
{
|
||||||
nativeHandle = getNativeReader(filename);
|
nativeHandle = getNativeReader(filename);
|
||||||
|
if (nativeHandle == 0) {
|
||||||
|
throw new JNIKiwixException("Cannot open zimfile "+filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public JNIKiwixReader() {
|
public JNIKiwixReader() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue