1 #ifndef JNI_EXCEPTION_HANDLING_H
2 #define JNI_EXCEPTION_HANDLING_H
9 namespace persistence {
12 static bool checkJavaExceptionNoThrow(std::vector<std::string> exceptionNames, std::string& error_msg)
16 while (jnipp::Env::hasException()) {
17 jnipp::LocalRef<JavaLangException> ex = jnipp::Env::getException();
18 ex->printStackTrace();
19 for(
auto exceptionName = exceptionNames.begin();exceptionName != exceptionNames.end(); exceptionName++)
20 if (ex->getClass()->getName()->std_str().compare(exceptionName->c_str()) == 0) {
21 error_msg += ex->getClass()->getName()->std_str() +
"(msg: " + ex->getMessage()->std_str() +
"), ";
28 static bool checkJavaExceptionNoThrow(std::string& error_msg)
32 while (jnipp::Env::hasException()) {
34 jnipp::LocalRef<JavaLangException> ex = jnipp::Env::getException();
35 ex->printStackTrace();
36 error_msg += ex->getClass()->getName()->std_str() +
"(msg: " + ex->getMessage()->std_str();
42 static void checkJavaExceptionThrow() {
45 if (checkJavaExceptionNoThrow(msg))
46 throw std::runtime_error(msg);
49 static bool checkJavaExceptionThrow(std::vector<std::string> exceptionNames)
53 if (checkJavaExceptionNoThrow(exceptionNames, msg))
54 throw std::runtime_error(msg);
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in c...
Definition: http_client.cpp:23