diff --git a/src/Bridges/bridge_optimizer.jl b/src/Bridges/bridge_optimizer.jl index a627f4cc0d..3c5dde6e82 100644 --- a/src/Bridges/bridge_optimizer.jl +++ b/src/Bridges/bridge_optimizer.jl @@ -569,10 +569,13 @@ function MOI.delete(b::AbstractBridgeOptimizer, ci::MOI.ConstraintIndex) MOI.throw_if_not_valid(b, ci) br = bridge(b, ci) if is_variable_bridged(b, ci) - error( - "Cannot delete constraint index of bridged constrained", - " variables. Delete the scalar variable or the vector of", - " variables instead.", + throw( + MOI.DeleteNotAllowed( + ci, + "Cannot delete constraint index of bridged constrained " * + "variables. Delete the scalar variable or the vector of " * + "variables instead.", + ), ) else delete!(Constraint.bridges(b), ci) diff --git a/test/Bridges/Variable/zeros.jl b/test/Bridges/Variable/zeros.jl index 3e1662eecd..a858eb82e4 100644 --- a/test/Bridges/Variable/zeros.jl +++ b/test/Bridges/Variable/zeros.jl @@ -72,9 +72,10 @@ function test_zeros() MOI.Bridges.IndexInVector(2), ) === nothing - err = ErrorException( - "Cannot delete constraint index of bridged constrained variables. Delete" * - " the scalar variable or the vector of variables instead.", + err = MOI.DeleteNotAllowed( + cyz, + "Cannot delete constraint index of bridged constrained variables. " * + "Delete the scalar variable or the vector of variables instead.", ) @test_throws err MOI.delete(bridged_mock, cyz)