Handle json parse failures
Summary: Loading the deviceId is not critical, so if it ever fails, we can live with that by swallowing the exception and using the default (possibly 'unknown' deviceId). Reviewed By: danielbuechele Differential Revision: D9682886 fbshipit-source-id: e5d60dd262fce683dd444167edd1475e0c029759
This commit is contained in:
committed by
Facebook Github Bot
parent
9cfb461a9a
commit
d16fd8cfae
@@ -64,9 +64,13 @@ std::string ConnectionContextStore::getDeviceId() {
|
|||||||
desktop app.
|
desktop app.
|
||||||
For backwards compatibility, when this isn't present, fall back to the
|
For backwards compatibility, when this isn't present, fall back to the
|
||||||
unreliable source. */
|
unreliable source. */
|
||||||
std::string config = loadStringFromFile(absoluteFilePath(CONNECTION_CONFIG_FILE));
|
try {
|
||||||
auto maybeDeviceId = folly::parseJson(config)["deviceId"];
|
std::string config = loadStringFromFile(absoluteFilePath(CONNECTION_CONFIG_FILE));
|
||||||
return maybeDeviceId.isString() ? maybeDeviceId.getString() : deviceData_.deviceId;
|
auto maybeDeviceId = folly::parseJson(config)["deviceId"];
|
||||||
|
return maybeDeviceId.isString() ? maybeDeviceId.getString() : deviceData_.deviceId;
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
return deviceData_.deviceId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionContextStore::storeConnectionConfig(folly::dynamic& config) {
|
void ConnectionContextStore::storeConnectionConfig(folly::dynamic& config) {
|
||||||
|
|||||||
Reference in New Issue
Block a user