From ca0cf11ca9fe1fd80c8edeb71d2a66016d9798d5 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 8 Aug 2019 15:07:36 +0100 Subject: feat: Improved error message for missing struct fields --- yants.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'yants.nix') diff --git a/yants.nix b/yants.nix index 3dfebfcf1fa0..a00d084392d3 100644 --- a/yants.nix +++ b/yants.nix @@ -35,7 +35,8 @@ with builtins; let type = def."${field}"; checked = type.check fieldVal; in if checked then (current && true) - else (throw "Field ${field} is of type ${typeOf fieldVal}, but expected ${type.name}"); + else if isNull fieldVal then (throw "Missing required ${type.name} field '${field}'") + else (throw "Field ${field} is of type ${typeOf fieldVal}, but expected ${type.name}"); checkExtraneous = name: def: present: if (length present) == 0 then true -- cgit 1.4.1