make invalid label index errors clearer
This commit is contained in:
@@ -1840,7 +1840,11 @@ std::string assemble_quest_script(const std::string& text) {
|
|||||||
label->name = line.substr(0, line.size() - 1);
|
label->name = line.substr(0, line.size() - 1);
|
||||||
size_t at_offset = label->name.find('@');
|
size_t at_offset = label->name.find('@');
|
||||||
if (at_offset != string::npos) {
|
if (at_offset != string::npos) {
|
||||||
|
try {
|
||||||
label->index = stoul(label->name.substr(at_offset + 1), nullptr, 0);
|
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);
|
label->name.resize(at_offset);
|
||||||
if (label->name == "start" && label->index != 0) {
|
if (label->name == "start" && label->index != 0) {
|
||||||
throw runtime_error("start label cannot have a nonzero label ID");
|
throw runtime_error("start label cannot have a nonzero label ID");
|
||||||
|
|||||||
Reference in New Issue
Block a user