Skip to content

Commit 6d1829e

Browse files
committed
A nicer error message
When extra varaibles are present or when variables are missing.
1 parent f7f378c commit 6d1829e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/variables.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,14 @@ creates the array of values in the correct order
213213
"""
214214
function varmap_to_vars(varmap::AbstractArray{<:Pair},varlist)
215215
out = similar(varmap,typeof(last(first(varmap))))
216-
for i in 1:length(varmap)
217-
ivar = varmap[i][1]
216+
for (ivar, ival) in varmap
218217
j = findfirst(isequal(ivar),varlist)
219-
out[j] = varmap[i][2]
218+
if isnothing(j)
219+
throw(ArgumentError("Value $(ivar) provided in map not found in $(varlist)"))
220+
elseif j > length(varmap)
221+
throw(ArgumentError("Missing value in $(varmap), need $(varlist)"))
222+
end
223+
out[j] = ival
220224
end
221225

222226
# Make output match varmap in type and shape

0 commit comments

Comments
 (0)