Skip to content

Commit a1cf400

Browse files
author
Alexey Stukalov
committed
streamline engine error throwing
1 parent 41c1308 commit a1cf400

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/optimizer/abstract.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
const optimizer_engine_dependencies =
2+
Dict(:NLopt => ["NLopt"], :Proximal => ["ProximalAlgorithms"])
3+
14
# throw unsupported engine error
25
function throw_engine_error(E)
36
if typeof(E) !== Symbol
47
throw(ArgumentError("engine argument must be a Symbol."))
5-
elseif E == :NLopt
6-
error("$E optimizer requires \"using NLopt\".")
7-
elseif E == :Proximal
8-
error("$E optimizer requires \"using ProximalAlgorithms\".")
8+
elseif haskey(optimizer_engine_dependencies, E)
9+
error(
10+
"optimizer \":$E\" requires \"using $(join(optimizer_engine_dependencies[E], ", "))\".",
11+
)
912
else
10-
error("$E optimizer engine is not supported.")
13+
error("optimizer engine \":$E\" is not supported.")
1114
end
1215
end
1316

0 commit comments

Comments
 (0)