diff --git a/xplat/Sonar/ConnectionContextStore.cpp b/xplat/Sonar/ConnectionContextStore.cpp index 8dd9a2634..6c89cdb8e 100644 --- a/xplat/Sonar/ConnectionContextStore.cpp +++ b/xplat/Sonar/ConnectionContextStore.cpp @@ -64,9 +64,13 @@ std::string ConnectionContextStore::getDeviceId() { desktop app. For backwards compatibility, when this isn't present, fall back to the unreliable source. */ - std::string config = loadStringFromFile(absoluteFilePath(CONNECTION_CONFIG_FILE)); - auto maybeDeviceId = folly::parseJson(config)["deviceId"]; - return maybeDeviceId.isString() ? maybeDeviceId.getString() : deviceData_.deviceId; + try { + std::string config = loadStringFromFile(absoluteFilePath(CONNECTION_CONFIG_FILE)); + 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) {