summaryrefslogtreecommitdiff
path: root/Source/Core/UICommon/CommandLineParse.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2017-11-26 18:24:01 +0100
committerLéo Lam <leo@innovatetechnologi.es>2017-11-26 18:24:01 +0100
commit05c8d229afc3d88f4c368a648e96b049ccd2fba3 (patch)
tree250d2da4cb45f697d2a10494dda8f4c025ae9acd /Source/Core/UICommon/CommandLineParse.cpp
parent653977cec758514027a0c73937b781f60c18ced9 (diff)
Config: Handle unknown system strings better
Currently, a simple typo in the system name will trigger an assert message that complains about a "programming error". This is not user friendly and misleading. So this changes GetSystemFromName to return an std::optional, which allows for callers to check whether the system exists and handle failures better.
Diffstat (limited to 'Source/Core/UICommon/CommandLineParse.cpp')
-rw-r--r--Source/Core/UICommon/CommandLineParse.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/Source/Core/UICommon/CommandLineParse.cpp b/Source/Core/UICommon/CommandLineParse.cpp
index 1ca4bb90e8..683738479f 100644
--- a/Source/Core/UICommon/CommandLineParse.cpp
+++ b/Source/Core/UICommon/CommandLineParse.cpp
@@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <list>
+#include <optional>
#include <sstream>
#include <string>
#include <tuple>
@@ -40,8 +41,12 @@ public:
std::getline(buffer, section, '.');
std::getline(buffer, key, '=');
std::getline(buffer, value, '=');
- Config::System system = Config::GetSystemFromName(system_str);
- m_values.emplace_back(std::make_tuple(Config::ConfigLocation{system, section, key}, value));
+ const std::optional<Config::System> system = Config::GetSystemFromName(system_str);
+ if (system)
+ {
+ m_values.emplace_back(
+ std::make_tuple(Config::ConfigLocation{*system, section, key}, value));
+ }
}
}