Android: pass non-critical server and mod errors to Java (#224)
parent
e76965f22a
commit
0d6fc71f2e
|
@ -191,4 +191,8 @@ public class GameActivity extends NativeActivity {
|
|||
public void finishGame(String exc) {
|
||||
finish();
|
||||
}
|
||||
|
||||
public void handleError(String message) {
|
||||
// Log errors from native
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ buildscript {
|
|||
maven { url 'https://plugins.gradle.org/m2/' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.0.0'
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21'
|
||||
classpath 'com.android.tools.build:gradle:7.0.3'
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31'
|
||||
classpath 'de.undercouch:gradle-download-task:4.1.1'
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
|
@ -4982,9 +4982,15 @@ void the_game(bool *kill,
|
|||
} catch (ServerError &e) {
|
||||
error_message = e.what();
|
||||
errorstream << "ServerError: " << error_message << std::endl;
|
||||
#ifdef __ANDROID__
|
||||
porting::handleError("ServerError", error_message);
|
||||
#endif
|
||||
} catch (ModError &e) {
|
||||
error_message = e.what() + strgettext("\nCheck debug.txt for details.");
|
||||
errorstream << "ModError: " << error_message << std::endl;
|
||||
#ifdef __ANDROID__
|
||||
porting::handleError("ModError", error_message);
|
||||
#endif
|
||||
}
|
||||
game.shutdown();
|
||||
g_game = NULL;
|
||||
|
|
|
@ -230,6 +230,9 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
|
|||
} catch (LuaError &e) {
|
||||
errorstream << "Main menu error: " << e.what() << std::endl;
|
||||
m_data->script_data.errormessage = e.what();
|
||||
#ifdef __ANDROID__
|
||||
porting::handleError("Main menu error", e.what());
|
||||
#endif
|
||||
}
|
||||
|
||||
m_menu->quitMenu();
|
||||
|
@ -255,6 +258,9 @@ bool GUIEngine::loadMainMenuScript()
|
|||
} catch (const ModError &e) {
|
||||
errorstream << "GUIEngine: execution of menu script failed: "
|
||||
<< e.what() << std::endl;
|
||||
#ifdef __ANDROID__
|
||||
porting::handleError("Main menu load error", e.what());
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -288,6 +288,18 @@ bool hasRealKeyboard()
|
|||
return device_has_keyboard;
|
||||
}
|
||||
|
||||
void handleError(const std::string &errType, const std::string &err) {
|
||||
jmethodID report_err = jnienv->GetMethodID(nativeActivity,
|
||||
"handleError","(Ljava/lang/String;)V");
|
||||
|
||||
FATAL_ERROR_IF(report_err == nullptr,
|
||||
"porting::handleError unable to find java handleError method");
|
||||
|
||||
std::string errorMessage = errType + ": " + err;
|
||||
jstring jerr = jnienv->NewStringUTF(errorMessage.c_str());
|
||||
jnienv->CallVoidMethod(app_global->activity->clazz, report_err, jerr);
|
||||
}
|
||||
|
||||
void notifyServerConnect(bool is_multiplayer)
|
||||
{
|
||||
jmethodID notifyConnect = jnienv->GetMethodID(nativeActivity,
|
||||
|
|
|
@ -91,4 +91,9 @@ std::string getInputDialogValue();
|
|||
* call Android function to finish
|
||||
*/
|
||||
void finishGame(const std::string &exc);
|
||||
|
||||
/**
|
||||
* call Android function to handle not-critical error
|
||||
*/
|
||||
void handleError(const std::string &errType, const std::string &err);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue