From 602806101cb296db4e53899f578446661f4f04a6 Mon Sep 17 00:00:00 2001 From: kobewi Date: Mon, 10 Mar 2025 23:14:37 +0100 Subject: [PATCH] Improve error messages for add_property_info() --- core/config/project_settings.cpp | 8 ++++++-- doc/classes/ProjectSettings.xml | 1 + editor/editor_settings.cpp | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index fc71a1fb27c..d6c6bb602cb 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1177,8 +1177,12 @@ Variant _GLOBAL_DEF(const PropertyInfo &p_info, const Variant &p_default, bool p } void ProjectSettings::_add_property_info_bind(const Dictionary &p_info) { - ERR_FAIL_COND(!p_info.has("name")); - ERR_FAIL_COND(!p_info.has("type")); + ERR_FAIL_COND_MSG(!p_info.has("name"), "Property info is missing \"name\" field."); + ERR_FAIL_COND_MSG(!p_info.has("type"), "Property info is missing \"type\" field."); + + if (p_info.has("usage")) { + WARN_PRINT("\"usage\" is not supported in add_property_info()."); + } PropertyInfo pinfo; pinfo.name = p_info["name"]; diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 24c9868081c..693185469b7 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -51,6 +51,7 @@ ProjectSettings.AddPropertyInfo(propertyInfo); [/csharp] [/codeblocks] + [b]Note:[/b] Setting [code]"usage"[/code] for the property is not supported. Use [method set_as_basic], [method set_restart_if_changed], and [method set_as_internal] to modify usage flags. diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index d8b13209a6e..b197e2fd604 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -320,8 +320,12 @@ void EditorSettings::_get_property_list(List *p_list) const { } void EditorSettings::_add_property_info_bind(const Dictionary &p_info) { - ERR_FAIL_COND(!p_info.has("name")); - ERR_FAIL_COND(!p_info.has("type")); + ERR_FAIL_COND_MSG(!p_info.has("name"), "Property info is missing \"name\" field."); + ERR_FAIL_COND_MSG(!p_info.has("type"), "Property info is missing \"type\" field."); + + if (p_info.has("usage")) { + WARN_PRINT("\"usage\" is not supported in add_property_info()."); + } PropertyInfo pinfo; pinfo.name = p_info["name"];