feat: Improved error message for missing struct fields

This commit is contained in:
Vincent Ambo 2019-08-08 15:07:36 +01:00
parent 4ebc069a3f
commit ca0cf11ca9
2 changed files with 2 additions and 1 deletions

View file

@ -35,7 +35,8 @@ with builtins; let
type = def."${field}"; type = def."${field}";
checked = type.check fieldVal; checked = type.check fieldVal;
in if checked then (current && true) 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: checkExtraneous = name: def: present:
if (length present) == 0 then true if (length present) == 0 then true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 68 KiB