about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-08-08T14·07+0100
committerVincent Ambo <tazjin@google.com>2019-08-28T13·36+0100
commitca0cf11ca9fe1fd80c8edeb71d2a66016d9798d5 (patch)
tree0fa8160e395cc16286418d44547baeb6b9e9d711
parent4ebc069a3f4b23aa9409be7b0363393556bdbdd4 (diff)
feat: Improved error message for missing struct fields
-rw-r--r--yants.nix3
-rw-r--r--z-structs.pngbin67989 -> 69499 bytes
2 files changed, 2 insertions, 1 deletions
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
--- a/z-structs.png
+++ b/z-structs.png
Binary files differ