mirror of
https://github.com/NixOS/nix.git
synced 2025-04-15 13:47:34 +00:00
Merge pull request #12942 from NixOS/mergify/bp/2.28-maintenance/pr-12936
libflake: add lock file path to invalid json error (backport #12936)
This commit is contained in:
commit
e3a8e43600
@ -108,8 +108,13 @@ LockFile::LockFile(
|
||||
const fetchers::Settings & fetchSettings,
|
||||
std::string_view contents, std::string_view path)
|
||||
{
|
||||
auto json = nlohmann::json::parse(contents);
|
||||
|
||||
auto json = [=] {
|
||||
try {
|
||||
return nlohmann::json::parse(contents);
|
||||
} catch (const nlohmann::json::parse_error & e) {
|
||||
throw Error("Could not parse '%s': %s", path, e.what());
|
||||
}
|
||||
}();
|
||||
auto version = json.value("version", 0);
|
||||
if (version < 5 || version > 7)
|
||||
throw Error("lock file '%s' has unsupported version %d", path, version);
|
||||
|
Loading…
Reference in New Issue
Block a user