Add try
/catch
around json parser
As got: ``` terminate called after throwing an instance of 'nlohmann::detail::parse_error' terminate called recursively what(): [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal terminate called recursively ```
This commit is contained in:
parent
dab4c8ff69
commit
292dd8919e
11
main.cpp
11
main.cpp
@ -310,7 +310,16 @@ json getJson(unsigned short threadId, string url, string directoryPath)
|
||||
string finalUrl = "https://www.googleapis.com/youtube/v3/" + url + "&key=" + API_KEY;
|
||||
#endif
|
||||
string content = getHttps(finalUrl);
|
||||
json data = json::parse(content);
|
||||
json data;
|
||||
try
|
||||
{
|
||||
data = json::parse(content);
|
||||
}
|
||||
catch (json::parse_error& ex)
|
||||
{
|
||||
PRINT(threadId, "Parse error for " << finalUrl << ", as got: " << content)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ostringstream toString;
|
||||
toString << CHANNELS_DIRECTORY << directoryPath << "/" << requestsPerChannel << ".json";
|
||||
|
Loading…
Reference in New Issue
Block a user