mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-14 06:40:40 +00:00
Use range_error for invalid indexes
This commit is contained in:
parent
fb0646dda1
commit
2a35bae655
@ -45,7 +45,7 @@ namespace LuaUi::Content
|
|||||||
if (index <= size())
|
if (index <= size())
|
||||||
mTable[toLua(index)] = table;
|
mTable[toLua(index)] = table;
|
||||||
else
|
else
|
||||||
throw std::domain_error("Invalid Content index");
|
throw std::range_error("Invalid Content index");
|
||||||
}
|
}
|
||||||
void insert(size_t index, const sol::table& table) { callMethod("insert", toLua(index), table); }
|
void insert(size_t index, const sol::table& table) { callMethod("insert", toLua(index), table); }
|
||||||
|
|
||||||
@ -54,14 +54,14 @@ namespace LuaUi::Content
|
|||||||
if (index < size())
|
if (index < size())
|
||||||
return mTable.get<sol::table>(toLua(index));
|
return mTable.get<sol::table>(toLua(index));
|
||||||
else
|
else
|
||||||
throw std::domain_error("Invalid Content index");
|
throw std::range_error("Invalid Content index");
|
||||||
}
|
}
|
||||||
sol::table at(std::string_view name) const
|
sol::table at(std::string_view name) const
|
||||||
{
|
{
|
||||||
if (indexOf(name).has_value())
|
if (indexOf(name).has_value())
|
||||||
return mTable.get<sol::table>(name);
|
return mTable.get<sol::table>(name);
|
||||||
else
|
else
|
||||||
throw std::domain_error("Invalid Content key");
|
throw std::range_error("Invalid Content key");
|
||||||
}
|
}
|
||||||
void remove(size_t index)
|
void remove(size_t index)
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ namespace LuaUi::Content
|
|||||||
mTable[sol::metatable_key][sol::meta_function::new_index].get<sol::protected_function>()(
|
mTable[sol::metatable_key][sol::meta_function::new_index].get<sol::protected_function>()(
|
||||||
mTable, toLua(index), sol::nil);
|
mTable, toLua(index), sol::nil);
|
||||||
else
|
else
|
||||||
throw std::domain_error("Invalid Content index");
|
throw std::range_error("Invalid Content index");
|
||||||
}
|
}
|
||||||
void remove(std::string_view name)
|
void remove(std::string_view name)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user