Changeset 2641


Ignore:
Timestamp:
Jun 4, 2010 3:36:24 PM (11 years ago)
Author:
prsteel
Message:

Changed an error message to be more informative.

Thought: the reason the original message wasn't very useful was
because pyomo can't show me the line in my model file that the error
is coming from; at best, pyomo shows the stack trace going through all
the different pyomo functions. This traceback is good for developers,
but not terribly useful for an end user debugging a model. Is there a
way to get pyomo to reference model file lines on errors?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/base/expr.py

    r2201 r2641  
    7272                raise ValueError, "Argument for expression "+self.name+" is a float!"
    7373            if (isinstance(arg,_ParamBase) or isinstance(arg,_VarBase)) and arg.dim() > 0:
    74                 raise ValueError, "Argument for expression "+self.name+" is an n-ary numeric value: "+arg.name
     74                msg = "Argument for expression '%s' is an n-ary numeric value: %s" % (self.name, arg.name)
     75                msg += "\n    Have you given variable or parameter '%s' an index?" % arg.name
     76                raise ValueError, msg
    7577
    7678    #
Note: See TracChangeset for help on using the changeset viewer.