Skip to content

Commit d5ae39b

Browse files
committed
More checks in settings parsing
1 parent 0c2bfaf commit d5ae39b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Phantasma.Core/Utils/ArgumentParser.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public string GetDefaultValue()
8282
throw new Exception("Not default argument found");
8383
}
8484

85-
public string GetString(string key, string defaultVal = null)
85+
public string GetString(string key, string defaultVal = null, bool required = false)
8686
{
8787
string result;
8888

@@ -100,13 +100,13 @@ public string GetString(string key, string defaultVal = null)
100100
result = null;
101101
}
102102

103-
if (result != null)
103+
if ((required && string.IsNullOrEmpty(result)) || (result != null && result.StartsWith("#")))
104104
{
105-
if (result.StartsWith("#"))
106-
{
107-
throw new Exception("Unconfigured setting: " + key);
108-
}
105+
throw new Exception("Unconfigured setting: " + key);
106+
}
109107

108+
if (result != null)
109+
{
110110
return result;
111111
}
112112

0 commit comments

Comments
 (0)