Provide better message a file is not found

This commit is contained in:
Arnaud 2025-12-24 10:28:58 +04:00
parent 60861d6af8
commit d85c87c288
No known key found for this signature in database
GPG Key ID: 20E40A5D3110766F

View File

@ -9,7 +9,12 @@ in {
let
linesFrom = file: splitString "\n" (fileContents file);
matching = regex: lines: map (line: match regex line) lines;
extractMatch = matches: last (flatten (remove null matches));
extractMatch = matches:
let xs = flatten (remove null matches);
in if xs == [] then
throw "findKeyValue: no match for regex '${regex}' in ${toString sourceFile}"
else
last xs;
in
extractMatch (matching regex (linesFrom sourceFile));
}