Add an error check for invalid JSON when importing a configuration.
This commit is contained in:
parent
219f407246
commit
f7453a1600
@ -918,7 +918,13 @@ namespace smx_config
|
||||
// Import a saved JSON configuration to an SMXConfig.
|
||||
public static void ImportSettingsFromJSON(string json, ref SMX.SMXConfig config)
|
||||
{
|
||||
Dictionary<string, Object> dict = SMXJSON.ParseJSON.Parse<Dictionary<string, Object>>(json);
|
||||
Dictionary<string, Object> dict;
|
||||
try {
|
||||
dict = SMXJSON.ParseJSON.Parse<Dictionary<string, Object>>(json);
|
||||
} catch(ParseError e) {
|
||||
MessageBox.Show(e.Message, "Error importing configuration", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the thresholds. If any values are missing, we'll leave the value in config alone.
|
||||
if(config.fsr())
|
||||
|
@ -9,7 +9,8 @@ namespace SMXJSON
|
||||
{
|
||||
public class JSONError: Exception
|
||||
{
|
||||
public JSONError(string error)
|
||||
public JSONError(string error):
|
||||
base(error)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user