@@ -35,35 +35,45 @@ the model, that is, that [`supports_constraint`](@ref) returns `false`.
3535
3636```jldoctest
3737julia> showerror(stdout, MOI.UnsupportedConstraint{MOI.VariableIndex,MOI.ZeroOne}())
38- UnsupportedConstraint: `MathOptInterface.VariableIndex`-in-`MathOptInterface.ZeroOne` constraints are not supported by the
39- solver you have chosen, and we could not reformulate your model into a
40- form that is supported.
38+ UnsupportedConstraint{
39+ MathOptInterface.VariableIndex,
40+ MathOptInterface.ZeroOne,
41+ }
4142
42- To fix this error you must choose a different solver.
43+ This constraint type is not supported by the solver.
4344
45+ To fix this error you must choose a different solver.
4446```
4547"""
4648struct UnsupportedConstraint{F<: AbstractFunction ,S<: AbstractSet } < :
4749 UnsupportedError
4850 # Human-friendly explanation why the attribute cannot be set
4951 message:: String
50- end
5152
52- UnsupportedConstraint {F,S} () where {F,S} = UnsupportedConstraint {F,S} (" " )
53+ function UnsupportedConstraint {F,S} (
54+ msg:: String = " " ,
55+ ) where {F<: AbstractFunction ,S<: AbstractSet }
56+ return new {F,S} (msg)
57+ end
58+ end
5359
5460function Base. showerror (io:: IO , err:: UnsupportedConstraint{F,S} ) where {F,S}
5561 print (
5662 io,
5763 """
58- UnsupportedConstraint: `$F `-in-`$S ` constraints are not supported by the
59- solver you have chosen, and we could not reformulate your model into a
60- form that is supported.
64+ UnsupportedConstraint{
65+ $F ,
66+ $S ,
67+ }
6168
62- To fix this error you must choose a different solver.
69+ This constraint type is not supported by the solver.
6370
64- $(err . message)
71+ To fix this error you must choose a different solver.
6572 """ ,
6673 )
74+ if ! isempty (err. message)
75+ print (io, " \n " , err. message)
76+ end
6777 return
6878end
6979
@@ -289,10 +299,16 @@ end
289299function Base. showerror (io:: IO , err:: LowerBoundAlreadySet{S1,S2} ) where {S1,S2}
290300 return print (
291301 io,
292- typeof (err),
293- " : Cannot add `VariableIndex`-in-`$(S2) ` constraint for variable " ,
294- " $(err. vi) as a `VariableIndex`-in-`$(S1) ` constraint was already " ,
295- " set for this variable and both constraints set a lower bound." ,
302+ """
303+ LowerBoundAlreadySet{
304+ $S1 ,
305+ $S2 ,
306+ }
307+
308+ You cannot add a `VariableIndex`-in-`$(S2) ` constraint for variable \
309+ $(err. vi) because a `VariableIndex`-in-`$(S1) ` constraint was already \
310+ set for this variable and both constraints define a lower bound.
311+ """ ,
296312 )
297313end
298314
@@ -311,10 +327,16 @@ end
311327function Base. showerror (io:: IO , err:: UpperBoundAlreadySet{S1,S2} ) where {S1,S2}
312328 return print (
313329 io,
314- typeof (err),
315- " : Cannot add `VariableIndex`-in-`$(S2) ` constraint for variable " ,
316- " $(err. vi) as a `VariableIndex`-in-`$(S1) ` constraint was already " ,
317- " set for this variable and both constraints set an upper bound." ,
330+ """
331+ UpperBoundAlreadySet{
332+ $S1 ,
333+ $S2 ,
334+ }
335+
336+ You cannot add a `VariableIndex`-in-`$(S2) ` constraint for variable \
337+ $(err. vi) because a `VariableIndex`-in-`$(S1) ` constraint was already \
338+ set for this variable and both constraints define an upper bound.
339+ """ ,
318340 )
319341end
320342
0 commit comments