improve gui properties-related error messages
This commit is contained in:
parent
45f845eb10
commit
c6f64c34ef
@ -490,6 +490,12 @@ static int p_get_scroll(UINode* node, 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 element = lua::require_string(L, 2);
|
||||
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});
|
||||
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);
|
||||
|
||||
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) {
|
||||
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 element = lua::require_string(L, 2);
|
||||
auto attr = lua::require_string(L, 3);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user