Skip to content

Commit 2e5e7da

Browse files
authored
[Bridges] throw GetAttributeNotAllowed in ZerosBridge (#2863)
1 parent 25c3358 commit 2e5e7da

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Bridges/Variable/bridges/ZerosBridge.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ end
9090

9191
function MOI.get(
9292
::MOI.ModelLike,
93-
::MOI.ConstraintDual,
93+
attr::MOI.ConstraintDual,
9494
::ZerosBridge{T},
9595
) where {T}
96-
return error(
96+
msg =
9797
"Unable to query the dual of a variable bound that was reformulated " *
9898
"using `ZerosBridge`. This usually arises in conic solvers when a " *
9999
"variable is fixed to a value. As a work-around, instead of creating " *
100100
"a fixed variable using variable bounds like `p == 1`, add an affine " *
101-
"equality constraint like `1 * p == 1` (or `[1 * p - 1,] in Zeros(1)`).",
102-
)
101+
"equality constraint like `1 * p == 1` (or `[1 * p - 1,] in Zeros(1)`)."
102+
return throw(MOI.GetAttributeNotAllowed(attr, msg))
103103
end
104104

105105
function MOI.get(

test/Bridges/Variable/zeros.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ function test_zeros()
175175
@test MOI.get(bridged_mock, MOI.ConstraintDual(), c1) == 0.0
176176
@test MOI.get(bridged_mock, MOI.ConstraintDual(), c2) == 1.0
177177
attr = MOI.ConstraintDual()
178-
err = ErrorException(
178+
err = MOI.GetAttributeNotAllowed(
179+
attr,
179180
"Unable to query the dual of a variable bound that was reformulated " *
180181
"using `ZerosBridge`. This usually arises in conic solvers when a " *
181182
"variable is fixed to a value. As a work-around, instead of creating " *

0 commit comments

Comments
 (0)