From d85c87c28849da2a13e428ec1c43d14285085fbe Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 24 Dec 2025 10:28:58 +0400 Subject: [PATCH] Provide better message a file is not found --- nix/tools.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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)); }