Skip to content

Commit b59a86d

Browse files
Merge pull request #1163 from jClugstor/keyword_checking
Add `checkkwarg` that takes Dict of allowed kwargs
2 parents a2bd7f2 + 02aaed3 commit b59a86d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/solve.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@ function checkkwargs(kwargshandle; kwargs...)
109109
end
110110
end
111111

112+
function checkkwargs(kwargshandle, allowed; kwargs...)
113+
if any(x -> x allowed, keys(kwargs))
114+
if kwargshandle == KeywordArgError
115+
throw(CommonKwargError(kwargs))
116+
elseif kwargshandle == KeywordArgWarn
117+
@warn KWARGWARN_MESSAGE
118+
unrecognized = setdiff(keys(kwargs), allowed)
119+
print("Unrecognized keyword arguments: ")
120+
printstyled(unrecognized; bold = true, color = :red)
121+
print("\n\n")
122+
else
123+
@assert kwargshandle == KeywordArgSilent
124+
end
125+
end
126+
end
112127
"""
113128
$(TYPEDSIGNATURES)
114129

0 commit comments

Comments
 (0)