From 5f9c85a1b53dc025398e00263f87bf87a16950d3 Mon Sep 17 00:00:00 2001 From: sterni Date: Wed, 8 Sep 2021 23:50:11 +0200 Subject: [PATCH] refactor(nix/readTree): use throw instead of assertMsg This gives a slightly prettier error message and won't leak the error message when builtins.tryEval is used. Currently an error message from the tests is always part of the pipeline evaluation log. Change-Id: I9b488a440368091ed42d707ba4124f592a64bd86 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3502 Tested-by: BuildkiteCI Reviewed-by: tazjin --- nix/readTree/default.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nix/readTree/default.nix b/nix/readTree/default.nix index 7c48d177f..f433b2736 100644 --- a/nix/readTree/default.nix +++ b/nix/readTree/default.nix @@ -66,10 +66,9 @@ let else import path; pathType = builtins.typeOf importedFile; imported = - assert assertMsg - (pathType == "lambda") - "readTree: trying to import ${toString path}, but it’s a ${pathType}, you need to make it a function like { depot, pkgs, ... }"; - importedFile (filter (argsWithPath args parts) parts); + if pathType != "lambda" + then builtins.throw "readTree: trying to import ${toString path}, but it’s a ${pathType}, you need to make it a function like { depot, pkgs, ... }" + else importedFile (filter (argsWithPath args parts) parts); in if (isAttrs imported) then imported // (marker parts) else imported;