Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw a more informative error for unsupported config dictionary entries #2844

Merged
merged 5 commits into from
Mar 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/solver/yaml_helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,17 @@ function override_default_config(config_dict::AbstractDict;)
for k in intersect(keys(config_dict), keys(default_config))
default_type = typeof(default_config[k])
v = config_dict[k]
config[k] = isnothing(default_config[k]) ? v : default_type(v)

# Attempt to convert user value `v` to the same type as
# the default. If that fails, throw an informative error.
config[k] = try
isnothing(default_config[k]) ? v : default_type(v)
catch err
user_entry_type = typeof(v)
msg = """Configuration entry "$(k)" = $v has type $(user_entry_type),
but must have type $default_type."""
throw(ArgumentError(msg))
end
end

# The "diagnostics" entry is a more complex type that doesn't fit the schema described in
Expand Down
Loading