diff --git a/src/Bridges/Variable/bridges/ZerosBridge.jl b/src/Bridges/Variable/bridges/ZerosBridge.jl index d2f005bcbd..7352055e4b 100644 --- a/src/Bridges/Variable/bridges/ZerosBridge.jl +++ b/src/Bridges/Variable/bridges/ZerosBridge.jl @@ -90,16 +90,16 @@ end function MOI.get( ::MOI.ModelLike, - ::MOI.ConstraintDual, + attr::MOI.ConstraintDual, ::ZerosBridge{T}, ) where {T} - return error( + msg = "Unable to query the dual of a variable bound that was reformulated " * "using `ZerosBridge`. This usually arises in conic solvers when a " * "variable is fixed to a value. As a work-around, instead of creating " * "a fixed variable using variable bounds like `p == 1`, add an affine " * - "equality constraint like `1 * p == 1` (or `[1 * p - 1,] in Zeros(1)`).", - ) + "equality constraint like `1 * p == 1` (or `[1 * p - 1,] in Zeros(1)`)." + return throw(MOI.GetAttributeNotAllowed(attr, msg)) end function MOI.get( diff --git a/test/Bridges/Variable/zeros.jl b/test/Bridges/Variable/zeros.jl index a531b199ef..5b73159ab3 100644 --- a/test/Bridges/Variable/zeros.jl +++ b/test/Bridges/Variable/zeros.jl @@ -175,7 +175,8 @@ function test_zeros() @test MOI.get(bridged_mock, MOI.ConstraintDual(), c1) == 0.0 @test MOI.get(bridged_mock, MOI.ConstraintDual(), c2) == 1.0 attr = MOI.ConstraintDual() - err = ErrorException( + err = MOI.GetAttributeNotAllowed( + attr, "Unable to query the dual of a variable bound that was reformulated " * "using `ZerosBridge`. This usually arises in conic solvers when a " * "variable is fixed to a value. As a work-around, instead of creating " *