Skip to content

Commit 1dc7e6c

Browse files
authored
Merge pull request #12936 from ajlekcahdp4/master
libflake: add lock file path to invalid json error
2 parents 3fcdccb + e3873aa commit 1dc7e6c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/libflake/flake/lockfile.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,13 @@ LockFile::LockFile(
108108
const fetchers::Settings & fetchSettings,
109109
std::string_view contents, std::string_view path)
110110
{
111-
auto json = nlohmann::json::parse(contents);
112-
111+
auto json = [=] {
112+
try {
113+
return nlohmann::json::parse(contents);
114+
} catch (const nlohmann::json::parse_error & e) {
115+
throw Error("Could not parse '%s': %s", path, e.what());
116+
}
117+
}();
113118
auto version = json.value("version", 0);
114119
if (version < 5 || version > 7)
115120
throw Error("lock file '%s' has unsupported version %d", path, version);

0 commit comments

Comments
 (0)