From 198db59816c5a621ed055cf67120b09386928e93 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sun, 11 Feb 2024 15:50:53 -0800 Subject: [PATCH] make invalid label index errors clearer --- src/QuestScript.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/QuestScript.cc b/src/QuestScript.cc index cee9b8db..0bcccdd2 100644 --- a/src/QuestScript.cc +++ b/src/QuestScript.cc @@ -1840,7 +1840,11 @@ std::string assemble_quest_script(const std::string& text) { label->name = line.substr(0, line.size() - 1); size_t at_offset = label->name.find('@'); if (at_offset != string::npos) { - label->index = stoul(label->name.substr(at_offset + 1), nullptr, 0); + try { + label->index = stoul(label->name.substr(at_offset + 1), nullptr, 0); + } catch (const exception& e) { + throw runtime_error(string_printf("(line %zu) invalid index in label (%s)", line_num, e.what())); + } label->name.resize(at_offset); if (label->name == "start" && label->index != 0) { throw runtime_error("start label cannot have a nonzero label ID");