Don't barf on registry parse errors

This commit is contained in:
Eelco Dolstra 2020-04-02 19:09:17 +02:00
parent a6ff66b658
commit 485a87f22f

View file

@ -17,6 +17,8 @@ std::shared_ptr<Registry> Registry::read(
if (!pathExists(path))
return std::make_shared<Registry>(type);
try {
auto json = nlohmann::json::parse(readFile(path));
auto version = json.value("version", 0);
@ -57,6 +59,9 @@ std::shared_ptr<Registry> Registry::read(
else
throw Error("flake registry '%s' has unsupported version %d", path, version);
} catch (nlohmann::json::exception & e) {
warn("cannot parse flake registry '%s': %s", path, e.what());
}
return registry;
}