On catching fatal error, prompt to save the log and report
This commit is contained in:
19
rsrc/dialogs/ask-save-replay.xml
Normal file
19
rsrc/dialogs/ask-save-replay.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
||||
<dialog defbtn='no'>
|
||||
<pict type='dlog' num='7' top='6' left='6'/>
|
||||
<text top='6' left='48' width='249'>
|
||||
Want to help improve OpenBoE?
|
||||
You can save and send a log of your session to help the developers solve this error.
|
||||
Click below to start your bug report (making a GitHub account if you don't have one),
|
||||
then save and upload your error log in a zip file.
|
||||
</text>
|
||||
<text colour='link' relative='pos-in pos' rel-anchor='prev' top='4' left='0' width='249'>
|
||||
https://github.com/calref/cboe/issues/new/
|
||||
</text>
|
||||
<text relative='pos-in pos' rel-anchor='prev' top='4' left='0' width='249'>
|
||||
Save a replay log?
|
||||
</text>
|
||||
<button name='no' relative='abs pos' rel-anchor='prev' type='regular' def-key='n' top='4' left='239'>No</button>
|
||||
<button name='yes' relative='abs pos-in' rel-anchor='prev' type='regular' def-key='y' top='0' left='172'>Yes</button>
|
||||
</dialog>
|
@@ -199,6 +199,17 @@ eMenuChoice menuChoice=eMenuChoice::MENU_CHOICE_NONE;
|
||||
short menuChoiceId=-1;
|
||||
#endif
|
||||
|
||||
static void handleFatalError(std::string what) {
|
||||
showFatalError(what);
|
||||
if(recording){
|
||||
record_action("error", what);
|
||||
extern fs::path log_file;
|
||||
if(log_file.empty() && cChoiceDlog("ask-save-replay", {"yes", "no"}).show() == "yes") {
|
||||
save_replay_log();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
#if 0
|
||||
void debug_oldstructs();
|
||||
@@ -231,13 +242,13 @@ int main(int argc, char* argv[]) {
|
||||
close_program();
|
||||
return 0;
|
||||
} catch(std::exception& x) {
|
||||
showFatalError(x.what());
|
||||
handleFatalError(x.what());
|
||||
throw;
|
||||
} catch(std::string& x) {
|
||||
showFatalError(x);
|
||||
handleFatalError(x);
|
||||
throw;
|
||||
} catch(...) {
|
||||
showFatalError("An unknown error occurred!");
|
||||
handleFatalError("An unknown error occurred!");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -941,6 +952,8 @@ static void replay_action(Element& action) {
|
||||
preview_every_dialog_xml();
|
||||
}else if(t == "clear_trapped_monst"){
|
||||
clear_trapped_monst();
|
||||
}else if(t == "error"){
|
||||
// The error is recorded for debugging only. It should be triggered by replaying the actions.
|
||||
}else if(t == "advance_time"){
|
||||
// This is bad regardless of strictness, because visual changes may have occurred which won't get redrawn/reprinted
|
||||
throw std::string { "Replay system internal error! advance_time() was supposed to be called by the last action, but wasn't: " } + _last_action_type;
|
||||
|
Reference in New Issue
Block a user