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 <mail@tazj.in>
This commit is contained in:
sterni 2021-09-08 23:50:11 +02:00
parent fab7dd62f4
commit 5f9c85a1b5

View file

@ -66,10 +66,9 @@ let
else import path;
pathType = builtins.typeOf importedFile;
imported =
assert assertMsg
(pathType == "lambda")
"readTree: trying to import ${toString path}, but its 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 its 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;