forked from lix-project/lix
Don't barf on registry parse errors
This commit is contained in:
parent
a6ff66b658
commit
485a87f22f
|
@ -17,6 +17,8 @@ std::shared_ptr<Registry> Registry::read(
|
||||||
if (!pathExists(path))
|
if (!pathExists(path))
|
||||||
return std::make_shared<Registry>(type);
|
return std::make_shared<Registry>(type);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
auto json = nlohmann::json::parse(readFile(path));
|
auto json = nlohmann::json::parse(readFile(path));
|
||||||
|
|
||||||
auto version = json.value("version", 0);
|
auto version = json.value("version", 0);
|
||||||
|
@ -57,6 +59,9 @@ std::shared_ptr<Registry> Registry::read(
|
||||||
else
|
else
|
||||||
throw Error("flake registry '%s' has unsupported version %d", path, version);
|
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;
|
return registry;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue