You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/onepass.jl throws a String for an unknown scheme, so typeof(e) === String. Callers
cannot dispatch on it, and any code following the ecosystem's exception conventions has nothing
typed to catch.
Reproduction
using OptimalControl, ExaModels, NLPModelsIpopt
ocp =@defbegin
t ∈ [0, 1], time
x = (q, v) ∈ R², state
u ∈ R, control
x(0) == [-1, 0]
x(1) == [0, 0]
∂(q)(t) ==v(t)
∂(v)(t) ==u(t)
∫(0.5u(t)^2) → min
endtrysolve(ocp, :exa; scheme=:gauss_legendre_2, display=false)
catch e
println("typeof = ", typeof(e))
println(e)
end
src/onepass.jl:941, and identically at :1035 and :1106:
throw(
"unknown numerical scheme: $scheme (possible choices are :euler, :euler_implicit, :midpoint, :trapeze)",
) # (vs. __throw) since raised at runtime (and __wrap-ped)
The adjacent comment says the choice is deliberate — __throw is avoided because the error is
raised at runtime inside __wrap-ped generated code. But __wrap rethrows whatever it caught,
so the type of the thrown object is preserved either way; nothing about the runtime context
requires it to be untyped.
Why it matters
The ecosystem's stated rule is seven typed exceptions under CTException, chosen so callers can
catch precisely. Three consequences here:
catch e ... e isa CTBase.Exceptions.IncorrectArgument never matches.
showerror(io, e) falls back to show, so the message renders with surrounding quotes
instead of the formatted │ Reason / Context / Hint block every other error in the ecosystem
produces.
CTBase.Exceptions.IncorrectArgument fits exactly: a single argument has an invalid value, and
the type carries got / expected / suggestion fields that already match what the message
spells out by hand.
Summary
src/onepass.jlthrows aStringfor an unknown scheme, sotypeof(e) === String. Callerscannot dispatch on it, and any code following the ecosystem's exception conventions has nothing
typed to catch.
Reproduction
Cause
src/onepass.jl:941, and identically at:1035and:1106:The adjacent comment says the choice is deliberate —
__throwis avoided because the error israised at runtime inside
__wrap-ped generated code. But__wraprethrows whatever it caught,so the type of the thrown object is preserved either way; nothing about the runtime context
requires it to be untyped.
Why it matters
The ecosystem's stated rule is seven typed exceptions under
CTException, chosen so callers cancatch precisely. Three consequences here:
catch e ... e isa CTBase.Exceptions.IncorrectArgumentnever matches.showerror(io, e)falls back toshow, so the message renders with surrounding quotesinstead of the formatted
│ Reason / Context / Hintblock every other error in the ecosystemproduces.
cannot use the Handbook's prescribed
@repl+showerrorform — the other twenty-nineconverted cleanly. See docs: display exceptions the way the Handbook prescribes OptimalControl.jl#878.
Suggested fix
CTBase.Exceptions.IncorrectArgumentfits exactly: a single argument has an invalid value, andthe type carries
got/expected/suggestionfields that already match what the messagespells out by hand.
🤖 Generated with Claude Code