diff --git a/nix/tools.nix b/nix/tools.nix index 108d3860..47e99450 100644 --- a/nix/tools.nix +++ b/nix/tools.nix @@ -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)); }