diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-03-24 22:49:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 22:49:50 +0100 |
commit | ca3596b043b2f4c5a4f6858bd6176b7d1cbc931a (patch) | |
tree | 15081004d0b8942c8683187aca60cec80a16b6c2 /core/io | |
parent | c25246d158c0d466d2b082803f3c86837e86b144 (diff) | |
parent | 927d15b815ff5bbc9693b98fb6ce177b84a76def (diff) |
Merge pull request #8098 from bojidar-bg/configfile-get-value-suppress
Suppress error messages when using ConfigFile::get_value and a default is given
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/config_file.cpp | 9 |
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]; } |