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 ++- z-structs.png | Bin 67989 -> 69499 bytes 2 files changed, 2 insertions(+), 1 deletion(-) 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 diff --git a/z-structs.png b/z-structs.png index f46e15ade5b2..fcbcf6415fad 100644 Binary files a/z-structs.png and b/z-structs.png differ -- cgit 1.4.1