File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,17 @@ cdef struct _Constraint
171171# #####################################################################
172172# Exceptions
173173
174- class LPException (Exception ): pass
174+ class LPException (Exception ):
175+ def __init__ (self , message , code = None , *args ):
176+ super (LPException, self ).__init__(message, code, * args)
177+ self .message = message
178+ self .code = code
179+
180+ def __str__ (self ):
181+ if self .code is None :
182+ return self .message
183+ return ' Error {}: {}' .format(self .code, self .message)
184+
175185class LPSuboptimalException (LPException ): pass
176186class LPInfeasibleException (LPException ): pass
177187class LPUnboundedException (LPException ): pass
@@ -2559,7 +2569,7 @@ cdef class LP(object):
25592569 elif ret == 13 :
25602570 # NOFEASFOUND (13) No feasible B&B solution found
25612571 raise LPInfeasibleException(" No feasible B&B solution found" , ret)
2562- raise LPException(" Error {}: Unknown error!" .format(ret) , ret)
2572+ raise LPException(" Unknown error!" , ret)
25632573
25642574 # And we're done
25652575
You can’t perform that action at this time.
0 commit comments