summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>2017-03-21 13:32:44 +0200
committerBojidar Marinov <bojidar.marinov.bg@gmail.com>2017-03-21 19:56:54 +0200
commit927d15b815ff5bbc9693b98fb6ce177b84a76def (patch)
tree2414516424bf4ddea5c09fb8cb329fa3f16a7fb5 /core/io
parent33a2c5def0f55ef67196e35ac3309d3f9b70d967 (diff)
Suppress error messages when using ConfigFile::get_value and a default is given
Fixes #8097
Diffstat (limited to 'core/io')
-rw-r--r--core/io/config_file.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index 052a83168d..6560302083 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -82,8 +82,13 @@ void ConfigFile::set_value(const String &p_section, const String &p_key, const V
}
Variant ConfigFile::get_value(const String &p_section, const String &p_key, Variant p_default) const {
- ERR_FAIL_COND_V(!values.has(p_section), p_default);
- ERR_FAIL_COND_V(!values[p_section].has(p_key), p_default);
+ if (!values.has(p_section) || !values[p_section].has(p_key)) {
+ if (p_default.get_type() == Variant::NIL) {
+ ERR_EXPLAIN("Couldn't find the given section/key and no default was given");
+ ERR_FAIL_V(p_default);
+ }
+ return p_default;
+ }
return values[p_section][p_key];
}