Skip to content

Fix Exception supertype of LowerBoundAlreadySet and UpperBoundAlreadySet #2397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2024
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
4 changes: 2 additions & 2 deletions src/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Error thrown when setting a `VariableIndex`-in-`S2` when a
set a lower bound, i.e. they are [`EqualTo`](@ref), [`GreaterThan`](@ref),
[`Interval`](@ref), [`Semicontinuous`](@ref) or [`Semiinteger`](@ref).
"""
struct LowerBoundAlreadySet{S1,S2}
struct LowerBoundAlreadySet{S1,S2} <: Exception
vi::VariableIndex
end

Expand All @@ -271,7 +271,7 @@ Error thrown when setting a `VariableIndex`-in-`S2` when a
set an upper bound, i.e. they are [`EqualTo`](@ref), [`LessThan`](@ref),
[`Interval`](@ref), [`Semicontinuous`](@ref) or [`Semiinteger`](@ref).
"""
struct UpperBoundAlreadySet{S1,S2}
struct UpperBoundAlreadySet{S1,S2} <: Exception
vi::VariableIndex
end

Expand Down
2 changes: 2 additions & 0 deletions test/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function test_LowerBoundAlreadySet_error()
S1 = MOI.LessThan{Int}
S2 = MOI.Interval{Int}
err = MOI.LowerBoundAlreadySet{S1,S2}(x)
@test err isa Exception
@test sprint(showerror, err) ==
"$(typeof(err)): Cannot add `VariableIndex`-in-`$(S2)` constraint " *
"for variable $(x) as a `VariableIndex`-in-`$(S1)` constraint was " *
Expand All @@ -57,6 +58,7 @@ function test_UpperBoundAlreadySet_error()
S1 = MOI.GreaterThan{Int}
S2 = MOI.Interval{Int}
err = MOI.UpperBoundAlreadySet{S1,S2}(x)
@test err isa Exception
@test sprint(showerror, err) ==
"$(typeof(err)): Cannot add `VariableIndex`-in-`$(S2)` constraint " *
"for variable $(x) as a `VariableIndex`-in-`$(S1)` constraint was " *
Expand Down