mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-14 15:31:49 +00:00
improve gui properties-related error messages
This commit is contained in:
parent
45f845eb10
commit
c6f64c34ef
1 changed files with 18 additions and 0 deletions
|
|
@ -490,6 +490,12 @@ static int p_get_scroll(UINode* node, lua::State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_gui_getattr(lua::State* L) {
|
static int l_gui_getattr(lua::State* L) {
|
||||||
|
if (!lua::isstring(L, 1)) {
|
||||||
|
throw std::runtime_error("document name is not a string");
|
||||||
|
}
|
||||||
|
if (!lua::isstring(L, 2)) {
|
||||||
|
throw std::runtime_error("element id is not a string");
|
||||||
|
}
|
||||||
auto docname = lua::require_string(L, 1);
|
auto docname = lua::require_string(L, 1);
|
||||||
auto element = lua::require_string(L, 2);
|
auto element = lua::require_string(L, 2);
|
||||||
if (lua::isnumber(L, 3)) {
|
if (lua::isnumber(L, 3)) {
|
||||||
|
|
@ -507,6 +513,9 @@ static int l_gui_getattr(lua::State* L) {
|
||||||
const auto& id = request_node_id(DocumentNode {docnode.document, node});
|
const auto& id = request_node_id(DocumentNode {docnode.document, node});
|
||||||
return push_document_node(L, id);
|
return push_document_node(L, id);
|
||||||
}
|
}
|
||||||
|
if (!lua::isstring(L, 3)) {
|
||||||
|
throw std::runtime_error("attribute name is not a string");
|
||||||
|
}
|
||||||
auto attr = lua::require_string(L, 3);
|
auto attr = lua::require_string(L, 3);
|
||||||
|
|
||||||
static const std::unordered_map<
|
static const std::unordered_map<
|
||||||
|
|
@ -755,6 +764,15 @@ static int p_set_scroll(UINode* node, lua::State* L, int idx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_gui_setattr(lua::State* L) {
|
static int l_gui_setattr(lua::State* L) {
|
||||||
|
if (!lua::isstring(L, 1)) {
|
||||||
|
throw std::runtime_error("document name is not a string");
|
||||||
|
}
|
||||||
|
if (!lua::isstring(L, 2)) {
|
||||||
|
throw std::runtime_error("element id is not a string");
|
||||||
|
}
|
||||||
|
if (!lua::isstring(L, 3)) {
|
||||||
|
throw std::runtime_error("attribute name is not a string");
|
||||||
|
}
|
||||||
auto docname = lua::require_string(L, 1);
|
auto docname = lua::require_string(L, 1);
|
||||||
auto element = lua::require_string(L, 2);
|
auto element = lua::require_string(L, 2);
|
||||||
auto attr = lua::require_string(L, 3);
|
auto attr = lua::require_string(L, 3);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue