Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion src/Bridges/bridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ function MOI.get(
)
return throw(
ArgumentError(
"Bridge of type `$(typeof(bridge))` does not support accessing the attribute `$attr`.",
"Bridge of type `$(typeof(bridge))` does not support accessing " *
"the attribute `$attr`. If you encountered this error " *
"unexpectedly, it probably means your model has been " *
"reformulated using the bridge, and you are attempting to query " *
"an attribute that we haven't implemented yet for this bridge. " *
"Please open an issue at https://github.com/jump-dev/MathOptInterface.jl/issues/new " *
"and provide a reproducible example explaining what you were " *
"trying to do.",
),
)
end
Expand Down
16 changes: 11 additions & 5 deletions test/Bridges/Variable/zeros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,19 @@ err = ArgumentError(
@test MOI.get(bridged_mock, MOI.ConstraintDual(), cx) == 0.0
@test MOI.get(bridged_mock, MOI.ConstraintDual(), c1) == 0.0
@test MOI.get(bridged_mock, MOI.ConstraintDual(), c2) == 1.0

bridge = MathOptInterface.Bridges.Variable.ZerosBridge{Float64}
attr = MOI.ConstraintDual()
err = ArgumentError(
"Bridge of type `MathOptInterface.Bridges.Variable.ZerosBridge{Float64}`" *
" does not support accessing the attribute" *
" `MathOptInterface.ConstraintDual(1)`.",
"Bridge of type `$(bridge)` does not support accessing " *
"the attribute `$attr`. If you encountered this error " *
"unexpectedly, it probably means your model has been " *
"reformulated using the bridge, and you are attempting to query " *
"an attribute that we haven't implemented yet for this bridge. " *
"Please open an issue at https://github.com/jump-dev/MathOptInterface.jl/issues/new " *
"and provide a reproducible example explaining what you were " *
"trying to do.",
)
@test_throws err MOI.get(bridged_mock, MOI.ConstraintDual(), cyz)
@test_throws err MOI.get(bridged_mock, attr, cyz)
end

@testset "Query" begin
Expand Down
17 changes: 15 additions & 2 deletions test/Bridges/bridge_optimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,23 @@ bridged_mock = MOIB.Constraint.LessToGreater{Float64}(
)

@testset "Unsupported constraint attribute" begin
bridge = MOI.Bridges.Constraint.SplitIntervalBridge{
Float64,
MOI.SingleVariable,
MOI.Interval{Float64},
MOI.GreaterThan{Float64},
MOI.LessThan{Float64},
}
attr = MOIT.UnknownConstraintAttribute()
err = ArgumentError(
"Bridge of type `$(MOI.Bridges.Constraint.SplitIntervalBridge{Float64,MOI.SingleVariable,MOI.Interval{Float64},MOI.GreaterThan{Float64},MOI.LessThan{Float64}})` " *
"does not support accessing the attribute `$attr`.",
"Bridge of type `$(bridge)` does not support accessing " *
"the attribute `$attr`. If you encountered this error " *
"unexpectedly, it probably means your model has been " *
"reformulated using the bridge, and you are attempting to query " *
"an attribute that we haven't implemented yet for this bridge. " *
"Please open an issue at https://github.com/jump-dev/MathOptInterface.jl/issues/new " *
"and provide a reproducible example explaining what you were " *
"trying to do.",
)
x = MOI.add_variable(bridged_mock)
ci = MOI.add_constraint(
Expand Down