Skip to content

Commit 7408ef5

Browse files
fix: improve error message for missing parameter values
1 parent 8df26b9 commit 7408ef5

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/systems/parameter_buffer.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function MTKParameters(
7070
end
7171
end
7272

73-
isempty(missing_params) || throw(MissingVariablesError(collect(missing_params)))
73+
isempty(missing_params) || throw(MissingParametersError(collect(missing_params)))
7474

7575
tunable_buffer = Tuple(Vector{temp.type}(undef, temp.length)
7676
for temp in ic.tunable_buffer_sizes)
@@ -574,3 +574,17 @@ function as_duals(p::MTKParameters, dualtype)
574574
discrete = dualtype.(p.discrete)
575575
return MTKParameters{typeof(tunable), typeof(discrete)}(tunable, discrete)
576576
end
577+
578+
const MISSING_PARAMETERS_MESSAGE = """
579+
Some parameters are missing from the variable map.
580+
Please provide a value or default for the following variables:
581+
"""
582+
583+
struct MissingParametersError <: Exception
584+
vars::Any
585+
end
586+
587+
function Base.showerror(io::IO, e::MissingParametersError)
588+
println(io, MISSING_PARAMETERS_MESSAGE)
589+
println(io, e.vars)
590+
end

0 commit comments

Comments
 (0)