Replay errors show line number of action

I would have done this FOREVER ago but every time I looked
in ticpp for a way to get element file positions I somehow
missed Row() and Column()
This commit is contained in:
2025-04-25 11:17:23 -05:00
parent c0008e183a
commit 973cd71627
4 changed files with 10 additions and 2 deletions

View File

@@ -603,7 +603,7 @@ void cDialog::handle_events() {
// The error is recorded for debugging only. It should be triggered by replaying the actions.
pop_next_action();
}else if(replaying && has_next_action()){
throw std::string { "Replaying a dialog, have the wrong replay action: " + next_action_type() };
throw std::string { "Replaying a dialog, have the wrong replay action: " + next_action_type() + " on line " + std::to_string(next_action_line()) };
}else{
while(pollEvent(win, currentEvent)){
handle_one_event(currentEvent, fps_limiter);

View File

@@ -984,7 +984,7 @@ static void replay_action(Element& action) {
throw std::string { "Replay system internal error! advance_time() was supposed to be called by the last action, but wasn't: " } + _last_action_type;
}else{
std::ostringstream sstr;
sstr << "Couldn't replay action: " << action;
sstr << "Couldn't replay action: " << action << " on line " << action.Row();
replaying = false;
throw sstr.str();
}

View File

@@ -202,6 +202,13 @@ std::string next_action_type() {
return next_action->Value();
}
int next_action_line() {
if(next_action == nullptr){
throw std::string { "Replay error! No action left to check row" };
}
return next_action->Row();
}
Element& pop_next_action(std::string expected_action_type) {
if(next_action == nullptr){
throw std::string { "Replay error! No action left to pop" };

View File

@@ -38,6 +38,7 @@ extern void record_action(Element& action);
extern void record_field_input(cKey key);
extern bool has_next_action(std::string type = "");
extern std::string next_action_type();
extern int next_action_line();
extern Element& pop_next_action(std::string expected_action_type="");
extern std::map<std::string,std::string> info_from_action(Element& action);
extern std::string encode_file(fs::path file);