Skip to content

Commit

Permalink
Fix Exception supertype of LowerBoundAlreadySet and UpperBoundAlready…
Browse files Browse the repository at this point in the history
…Set (#2397)
  • Loading branch information
odow authored Jan 8, 2024
1 parent 9a790ca commit 79c19e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit 79c19e0

Please sign in to comment.