1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 09:49:19 +02:00

exception throwing (in progress)

This commit is contained in:
Nikolay Pultsin 2012-04-07 12:52:27 +01:00
parent 06660e99e2
commit 85f1714ddc
2 changed files with 12 additions and 3 deletions

View file

@ -38,6 +38,7 @@ JavaClass AndroidUtil::Class_ZLibrary("org/geometerplus/zlibrary/core/library/ZL
JavaClass AndroidUtil::Class_ZLFile("org/geometerplus/zlibrary/core/filesystem/ZLFile");
JavaClass AndroidUtil::Class_ZLFileImage("org/geometerplus/zlibrary/core/image/ZLFileImage");
JavaClass AndroidUtil::Class_ZLTextModel("org/geometerplus/zlibrary/text/model/ZLTextModel");
JavaClass AndroidUtil::Class_CachedCharStorageException("org/geometerplus/zlibrary/text/model/CachedCharStorageException");
JavaClass AndroidUtil::Class_Encoding("org/geometerplus/zlibrary/core/encodings/Encoding");
JavaClass AndroidUtil::Class_EncodingConverter("org/geometerplus/zlibrary/core/encodings/EncodingConverter");
@ -273,8 +274,14 @@ jbyteArray AndroidUtil::createJavaByteArray(JNIEnv *env, const std::vector<jbyte
return array;
}
void AndroidUtil::throwRuntimeException(JNIEnv *env, const std::string &message) {
env->ThrowNew(Class_java_lang_RuntimeException.j(), message.c_str());
void AndroidUtil::throwRuntimeException(const std::string &message) {
JNIEnv *env = getEnv();
getEnv()->ThrowNew((jclass)env->NewLocalRef(Class_java_lang_RuntimeException.j()), message.c_str());
}
void AndroidUtil::throwCachedCharStorageException(const std::string &message) {
JNIEnv *env = getEnv();
getEnv()->ThrowNew((jclass)env->NewLocalRef(Class_CachedCharStorageException.j()), message.c_str());
}
/*

View file

@ -61,6 +61,7 @@ public:
static JavaClass Class_ZLFile;
static JavaClass Class_ZLFileImage;
static JavaClass Class_ZLTextModel;
static JavaClass Class_CachedCharStorageException;
static JavaClass Class_NativeFormatPlugin;
static JavaClass Class_PluginCollection;
static JavaClass Class_Encoding;
@ -153,7 +154,8 @@ public:
static jintArray createJavaIntArray(JNIEnv *env, const std::vector<jint> &data);
static jbyteArray createJavaByteArray(JNIEnv *env, const std::vector<jbyte> &data);
static void throwRuntimeException(JNIEnv *env, const std::string &message);
static void throwRuntimeException(const std::string &message);
static void throwCachedCharStorageException(const std::string &message);
//static void throwBookReadingException(const std::string &resourceId, const ZLFile &file);
};