summaryrefslogtreecommitdiffstats
path: root/core/io/config_file.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/io/config_file.cpp')
-rw-r--r--core/io/config_file.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index 052a83168d..4067899068 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -82,8 +83,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];
}